]> granicus.if.org Git - python/commitdiff
#3911 FTP.makeport was giving bad port numbers
authorBenjamin Peterson <benjamin@python.org>
Sat, 27 Sep 2008 22:04:16 +0000 (22:04 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sat, 27 Sep 2008 22:04:16 +0000 (22:04 +0000)
reviewed by Benjamin and Antoine

Lib/ftplib.py
Lib/test/test_ftplib.py
Misc/NEWS

index c75b31740c59b2054a31cabe49bd829af2f8c477..42f2bff9fa53078075e2f5ba3677375818832c2b 100644 (file)
@@ -254,7 +254,7 @@ class FTP:
         port number.
         '''
         hbytes = host.split('.')
-        pbytes = [repr(port/256), repr(port%256)]
+        pbytes = [repr(port//256), repr(port%256)]
         bytes = hbytes + pbytes
         cmd = 'PORT ' + ','.join(bytes)
         return self.voidcmd(cmd)
index 10eabba8ebc94dde41dd37d4e3b993783780dacc..ae889f96c6f12af9485567218d01f7cf6c1386be 100644 (file)
@@ -348,7 +348,7 @@ class TestFTPClass(TestCase):
         self.client.dir(lambda x: l.append(x))
         self.assertEqual(''.join(l), LIST_DATA.replace('\r\n', ''))
 
-    def Xtest_makeport(self):
+    def test_makeport(self):
         self.client.makeport()
         # IPv4 is in use, just make sure send_eprt has not been used
         self.assertEqual(self.server.handler.last_received_cmd, 'port')
index 294c183e1c8675f8ec184ad16f01631300e8dc2d..d4d0b42edcc65cba70f6a52f002ba9edf0358cc7 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -22,6 +22,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #3911: ftplib.FTP.makeport() could give invalid port numbers.
+
 - Issue #3929: When the database cannot be opened, dbm.open() would incorrectly
   raise a TypeError: "'tuple' object is not callable" instead of the expected
   dbm.error.