]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #23881: urllib.ftpwrapper constructor now closes the socket if the FTP
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 7 Apr 2015 10:47:57 +0000 (12:47 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 7 Apr 2015 10:47:57 +0000 (12:47 +0200)
connection failed.

Lib/urllib.py
Misc/NEWS

index 2408cb8840c5d2dc77e6118db3200cc5f9b5fa09..9f972e3c1d40957bcbe71f8f4e52ba4f93d41681 100644 (file)
@@ -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
index c9febc7b5ecfcd29fd7c70ab064fd9591c990f6f..3f24df1bea76caf338bc23d31eb462966cc7a5e4 100644 (file)
--- 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