From: Victor Stinner Date: Tue, 7 Apr 2015 10:47:57 +0000 (+0200) Subject: Issue #23881: urllib.ftpwrapper constructor now closes the socket if the FTP X-Git-Tag: v2.7.10rc1~64 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5ab1c01bfd1b5a825aafa214016b8441f7325081;p=thirdparty%2FPython%2Fcpython.git Issue #23881: urllib.ftpwrapper constructor now closes the socket if the FTP connection failed. --- diff --git a/Lib/urllib.py b/Lib/urllib.py index 2408cb8840c5..9f972e3c1d40 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -871,7 +871,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 diff --git a/Misc/NEWS b/Misc/NEWS index c9febc7b5ecf..3f24df1bea76 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -21,6 +21,9 @@ Core and Builtins Library ------- +- Issue #23881: urllib.ftpwrapper constructor now closes the socket if the FTP + connection failed. + - Issue #15133: _tkinter.tkapp.getboolean() now supports long and Tcl_Obj and always returns bool. tkinter.BooleanVar now validates input values (accepted bool, int, long, str, unicode, and Tcl_Obj). tkinter.BooleanVar.get() now