diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-04-07 12:49:27 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-04-07 12:49:27 +0200 |
commit | ed425281fc1bbd7fffedaede15c92b51992281f8 (patch) | |
tree | 0fa7f7b3db93654ae4783ca72510e1799962649d /Lib/urllib/request.py | |
parent | 4488726ba566c7c0333d6b5607f2a303333aae3e (diff) | |
download | cpython-ed425281fc1bbd7fffedaede15c92b51992281f8.tar.gz |
Issue #23881: urllib.request.ftpwrapper constructor now closes the socket if
the FTP connection failed to fix a ResourceWarning.
Diffstat (limited to 'Lib/urllib/request.py')
-rw-r--r-- | Lib/urllib/request.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 6da9007ac8..5cf0cf2e86 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 |