From 1ae7abf6b2f410feee02286a1b2179f2c6e88abd Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sun, 9 Oct 2022 23:36:51 -0700 Subject: [3.10] bpo-43564: preserve original exception in args of FTP URLError (GH-24938) (#98138) * bpo-43564: preserve original error in args of FTP URLError * Add NEWS blurb Co-authored-by: Carl Meyer . (cherry picked from commit ad817cd5c44416da3752ebf9baf16d650703275c) Co-authored-by: Carl Meyer Co-authored-by: Carl Meyer --- Lib/urllib/request.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Lib/urllib/request.py') diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 320163be63..76fdd719cd 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -1579,8 +1579,7 @@ class FTPHandler(BaseHandler): headers = email.message_from_string(headers) return addinfourl(fp, headers, req.full_url) except ftplib.all_errors as exp: - exc = URLError('ftp error: %r' % exp) - raise exc.with_traceback(sys.exc_info()[2]) + raise URLError(exp) from exp def connect_ftp(self, user, passwd, host, port, dirs, timeout): return ftpwrapper(user, passwd, host, port, dirs, timeout, -- cgit v1.2.1