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

Skip to content

Commit 1bd93a7

Browse files
committed
fix ftplib resource warnings
1 parent d5df36d commit 1bd93a7

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

Lib/ftplib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ def ntransfercmd(self, cmd, rest=None):
361361
conn, sockaddr = sock.accept()
362362
if self.timeout is not _GLOBAL_DEFAULT_TIMEOUT:
363363
conn.settimeout(self.timeout)
364+
sock.close()
364365
if resp[:3] == '150':
365366
# this is conditional in case we received a 125
366367
size = parse150(resp)

Lib/test/test_ftplib.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,8 @@ def close(self):
355355
if (isinstance(self.socket, ssl.SSLSocket) and
356356
self.socket._sslobj is not None):
357357
self._do_ssl_shutdown()
358+
else:
359+
super(SSLConnection, self).close()
358360

359361

360362
class DummyTLS_DTPHandler(SSLConnection, DummyDTPHandler):

0 commit comments

Comments
 (0)