]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43564: preserve original exception in args of FTP URLError (GH-24938)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 10 Oct 2022 05:09:12 +0000 (22:09 -0700)
committerGitHub <noreply@github.com>
Mon, 10 Oct 2022 05:09:12 +0000 (22:09 -0700)
* 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 ad817cd5c44416da3752ebf9baf16d650703275c)

Co-authored-by: Carl Meyer <carl@oddbird.net>
Lib/urllib/request.py
Misc/NEWS.d/next/Library/2022-10-09-12-12-38.gh-issue-87730.ClgP3f.rst [new file with mode: 0644]

index 6d580a434a7bea01a745124352a7be1738bc6a7c..73ad0127ecc969320e25a3d3608955471486f791 100644 (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,
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 (file)
index 0000000..6c63fa4
--- /dev/null
@@ -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.