Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3a53fbb

Browse files
committed
#3911 FTP.makeport was giving bad port numbers
reviewed by Benjamin and Antoine
1 parent be17a11 commit 3a53fbb

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

Lib/ftplib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def sendport(self, host, port):
254254
port number.
255255
'''
256256
hbytes = host.split('.')
257-
pbytes = [repr(port/256), repr(port%256)]
257+
pbytes = [repr(port//256), repr(port%256)]
258258
bytes = hbytes + pbytes
259259
cmd = 'PORT ' + ','.join(bytes)
260260
return self.voidcmd(cmd)

Lib/test/test_ftplib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def test_dir(self):
348348
self.client.dir(lambda x: l.append(x))
349349
self.assertEqual(''.join(l), LIST_DATA.replace('\r\n', ''))
350350

351-
def Xtest_makeport(self):
351+
def test_makeport(self):
352352
self.client.makeport()
353353
# IPv4 is in use, just make sure send_eprt has not been used
354354
self.assertEqual(self.server.handler.last_received_cmd, 'port')

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Core and Builtins
2222
Library
2323
-------
2424

25+
- Issue #3911: ftplib.FTP.makeport() could give invalid port numbers.
26+
2527
- Issue #3929: When the database cannot be opened, dbm.open() would incorrectly
2628
raise a TypeError: "'tuple' object is not callable" instead of the expected
2729
dbm.error.

0 commit comments

Comments
 (0)