From ad817cd5c44416da3752ebf9baf16d650703275c Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Mon, 10 Oct 2022 03:59:07 +0200 Subject: bpo-43564: preserve original exception in args of FTP URLError (#24938) * bpo-43564: preserve original error in args of FTP URLError * Add NEWS blurb Co-authored-by: Carl Meyer --- Lib/urllib/request.py | 2 +- Misc/NEWS.d/next/Library/2022-10-09-12-12-38.gh-issue-87730.ClgP3f.rst | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2022-10-09-12-12-38.gh-issue-87730.ClgP3f.rst diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index e2d5b8c..278aa3a 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -1582,7 +1582,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, diff --git a/Misc/NEWS.d/next/Library/2022-10-09-12-12-38.gh-issue-87730.ClgP3f.rst b/Misc/NEWS.d/next/Library/2022-10-09-12-12-38.gh-issue-87730.ClgP3f.rst new file mode 100644 index 0000000..6c63fa4 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-10-09-12-12-38.gh-issue-87730.ClgP3f.rst @@ -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. -- cgit v0.12