diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-04-07 10:49:27 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-04-07 10:49:27 (GMT) |
commit | ab73e65032565029fdd00e73936dc3b4a197bef6 (patch) | |
tree | ce5bbb2eb974b14f27a5c3447c664a91e24118ba | |
parent | fe508d1592df5bf22e98219ece3490dd1cc58d6e (diff) | |
download | cpython-ab73e65032565029fdd00e73936dc3b4a197bef6.zip cpython-ab73e65032565029fdd00e73936dc3b4a197bef6.tar.gz cpython-ab73e65032565029fdd00e73936dc3b4a197bef6.tar.bz2 |
Issue #23881: urllib.request.ftpwrapper constructor now closes the socket if
the FTP connection failed to fix a ResourceWarning.
-rw-r--r-- | Lib/urllib/request.py | 6 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 6da9007..5cf0cf2 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -2240,7 +2240,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 @@ -24,6 +24,9 @@ Core and Builtins 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. |