[Python-checkins] cpython (2.7): Issue #23881: urllib.ftpwrapper constructor now closes the socket if the FTP
victor.stinner
python-checkins at python.org
Tue Apr 7 12:50:48 CEST 2015
https://hg.python.org/cpython/rev/69d4e199b88e
changeset: 95466:69d4e199b88e
branch: 2.7
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Apr 07 12:47:57 2015 +0200
summary:
Issue #23881: urllib.ftpwrapper constructor now closes the socket if the FTP
connection failed.
files:
Lib/urllib.py | 6 +++++-
Misc/NEWS | 3 +++
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/Lib/urllib.py b/Lib/urllib.py
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -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 --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -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
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list