[Python-checkins] cpython (3.4): Issue #23881: urllib.request.ftpwrapper constructor now closes the socket if
victor.stinner
python-checkins at python.org
Tue Apr 7 12:50:48 CEST 2015
https://hg.python.org/cpython/rev/7b168db16e67
changeset: 95467:7b168db16e67
branch: 3.4
parent: 95463:7e2a7de211b4
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Apr 07 12:49:27 2015 +0200
summary:
Issue #23881: urllib.request.ftpwrapper constructor now closes the socket if
the FTP connection failed to fix a ResourceWarning.
files:
Lib/urllib/request.py | 6 +++++-
Misc/NEWS | 3 +++
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -2240,7 +2240,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
@@ -24,6 +24,9 @@
Library
-------
+- Issue #23881: urllib.request.ftpwrapper constructor now closes the socket if
+ the FTP connection failed to fix a ResourceWarning.
+
- Issue #15133: _tkinter.tkapp.getboolean() now supports Tcl_Obj and always
returns bool. tkinter.BooleanVar now validates input values (accepted bool,
int, str, and Tcl_Obj). tkinter.BooleanVar.get() now always returns bool.
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list