commit | 5ab1c01bfd1b5a825aafa214016b8441f7325081 | [log] [tgz] |
---|---|---|
author | Victor Stinner <victor.stinner@gmail.com> | Tue Apr 07 12:47:57 2015 +0200 |
committer | Victor Stinner <victor.stinner@gmail.com> | Tue Apr 07 12:47:57 2015 +0200 |
tree | 6a7f255097a7212eb9e499a871075991eb0f94f0 | |
parent | d27bcbd706200c4aebfb475d587bf2460f2c197e [diff] |
Issue #23881: urllib.ftpwrapper constructor now closes the socket if the FTP connection failed.
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 @@ self.timeout = timeout self.refcount = 0 self.keepalive = persistent - self.init() + try: + self.init() + except: + self.close() + raise def init(self): import ftplib