[PATCH 08 of 13] Fix import for the undocumented urllib ftpwrapper class, wich the 2to3 knows nothing about

Alejandro Santos alejolp at alejolp.com
Wed Aug 5 15:55:42 CDT 2009


# HG changeset patch
# User Alejandro Santos <alejolp at alejolp.com>
# Date 1249505636 10800
# Node ID 33bef15b45baf422fb233d40b723905e7f810e18
# Parent  11bc534a8f1d09a9d7c24b0e0c55d258a0782ab3
Fix import for the undocumented urllib ftpwrapper class, wich the 2to3 knows nothing about.

diff -r 11bc534a8f1d -r 33bef15b45ba mercurial/byterange.py
--- a/mercurial/byterange.py	Wed Aug 05 17:53:56 2009 -0300
+++ b/mercurial/byterange.py	Wed Aug 05 17:53:56 2009 -0300
@@ -19,12 +19,17 @@
 
 # $Id: byterange.py,v 1.9 2005/02/14 21:55:07 mstenner Exp $
 
-import os
+import os, sys
 import stat
 import urllib
 import urllib2
 import email.Utils
 
+if sys.version_info[0] == 2:
+    _ftpwrapper = urllib.ftpwrapper
+else:
+    _ftpwrapper = urllib.request.ftpwrapper
+
 try:
     from cStringIO import StringIO
 except ImportError, msg:
@@ -334,7 +339,7 @@
         fw = ftpwrapper(user, passwd, host, port, dirs)
         return fw
 
-class ftpwrapper(urllib.ftpwrapper):
+class ftpwrapper(_ftpwrapper):
     # range support note:
     # this ftpwrapper code is copied directly from
     # urllib. The only enhancement is to add the rest


More information about the Mercurial-devel mailing list