From 1bd93a754fc0f9a801c982ab1bb3a8ee0d9d77b6 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sun, 31 Oct 2010 19:58:07 +0000 Subject: fix ftplib resource warnings --- Lib/ftplib.py | 1 + Lib/test/test_ftplib.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Lib/ftplib.py b/Lib/ftplib.py index 50dbacc..22b5fd2 100644 --- a/Lib/ftplib.py +++ b/Lib/ftplib.py @@ -361,6 +361,7 @@ class FTP: conn, sockaddr = sock.accept() if self.timeout is not _GLOBAL_DEFAULT_TIMEOUT: conn.settimeout(self.timeout) + sock.close() if resp[:3] == '150': # this is conditional in case we received a 125 size = parse150(resp) diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py index a7ea254..9d2eab7 100644 --- a/Lib/test/test_ftplib.py +++ b/Lib/test/test_ftplib.py @@ -355,6 +355,8 @@ if ssl is not None: if (isinstance(self.socket, ssl.SSLSocket) and self.socket._sslobj is not None): self._do_ssl_shutdown() + else: + super(SSLConnection, self).close() class DummyTLS_DTPHandler(SSLConnection, DummyDTPHandler): -- cgit v0.12