changeset: 95466:69d4e199b88e branch: 2.7 user: Victor Stinner date: Tue Apr 07 12:47:57 2015 +0200 files: Lib/urllib.py Misc/NEWS description: Issue #23881: urllib.ftpwrapper constructor now closes the socket if the FTP connection failed. diff -r be8b1895897c -r 69d4e199b88e Lib/urllib.py --- a/Lib/urllib.py Tue Apr 07 01:32:24 2015 -0400 +++ b/Lib/urllib.py Tue Apr 07 12:47:57 2015 +0200 @@ -871,7 +871,11 @@ self.timeout = timeout self.refcount = 0 self.keepalive = persistent - self.init() + try: + self.init() + except: + self.close() + raise def init(self): import ftplib diff -r be8b1895897c -r 69d4e199b88e Misc/NEWS --- a/Misc/NEWS Tue Apr 07 01:32:24 2015 -0400 +++ b/Misc/NEWS Tue Apr 07 12:47:57 2015 +0200 @@ -21,6 +21,9 @@ 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