(Merge 3.4) Issue #23881: urllib.request.ftpwrapper constructor now closes the

socket if the FTP connection failed to fix a ResourceWarning.
This commit is contained in:
Victor Stinner 2015-04-07 12:50:24 +02:00
commit a9dd680d23
2 changed files with 8 additions and 1 deletions

View file

@ -2255,7 +2255,11 @@ class ftpwrapper:
self.timeout = timeout
self.refcount = 0
self.keepalive = persistent
self.init()
try:
self.init()
except:
self.close()
raise
def init(self):
import ftplib