summaryrefslogtreecommitdiffstats
path: root/Lib/urllib.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-04-07 10:47:57 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-04-07 10:47:57 (GMT)
commit5ab1c01bfd1b5a825aafa214016b8441f7325081 (patch)
tree6a7f255097a7212eb9e499a871075991eb0f94f0 /Lib/urllib.py
parentd27bcbd706200c4aebfb475d587bf2460f2c197e (diff)
downloadcpython-5ab1c01bfd1b5a825aafa214016b8441f7325081.zip
cpython-5ab1c01bfd1b5a825aafa214016b8441f7325081.tar.gz
cpython-5ab1c01bfd1b5a825aafa214016b8441f7325081.tar.bz2
Issue #23881: urllib.ftpwrapper constructor now closes the socket if the FTP
connection failed.
Diffstat (limited to 'Lib/urllib.py')
-rw-r--r--Lib/urllib.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py
index 2408cb8..9f972e3 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -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