bpo-43564: preserve original exception in args of FTP URLError (GH-24938)

* bpo-43564: preserve original error in args of FTP URLError

* Add NEWS blurb

Co-authored-by: Carl Meyer <carljm@instagram.com>
(cherry picked from commit ad817cd5c4)

Co-authored-by: Carl Meyer <carl@oddbird.net>
This commit is contained in:
Miss Islington (bot) 2022-10-09 22:09:12 -07:00 committed by GitHub
parent 21b13c24ba
commit 1d05b58e83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -1579,7 +1579,7 @@ class FTPHandler(BaseHandler):
headers = email.message_from_string(headers)
return addinfourl(fp, headers, req.full_url)
except ftplib.all_errors as exp:
raise URLError(f'ftp error: {exp}') from exp
raise URLError(exp) from exp
def connect_ftp(self, user, passwd, host, port, dirs, timeout):
return ftpwrapper(user, passwd, host, port, dirs, timeout,

View file

@ -0,0 +1,3 @@
Wrap network errors consistently in urllib FTP support, so the test suite
doesn't fail when a network is available but the public internet is not
reachable.