From 3a53fbbfcf2785ff5ed738a0e592973a7dae1dfc Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sat, 27 Sep 2008 22:04:16 +0000 Subject: #3911 FTP.makeport was giving bad port numbers reviewed by Benjamin and Antoine --- Lib/ftplib.py | 2 +- Lib/test/test_ftplib.py | 2 +- Misc/NEWS | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/ftplib.py b/Lib/ftplib.py index c75b317..42f2bff 100644 --- a/Lib/ftplib.py +++ b/Lib/ftplib.py @@ -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) diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py index 10eabba..ae889f9 100644 --- a/Lib/test/test_ftplib.py +++ b/Lib/test/test_ftplib.py @@ -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') diff --git a/Misc/NEWS b/Misc/NEWS index 294c183..d4d0b42 100644 --- 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. -- cgit v0.12