Skip to content

Commit 1ae7abf

Browse files
orsenthilcarljm
andauthored
[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 <[email protected]>. (cherry picked from commit ad817cd) Co-authored-by: Carl Meyer <[email protected]> Co-authored-by: Carl Meyer <[email protected]>
1 parent ac0a19b commit 1ae7abf

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Lib/urllib/request.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,8 +1579,7 @@ def ftp_open(self, req):
15791579
headers = email.message_from_string(headers)
15801580
return addinfourl(fp, headers, req.full_url)
15811581
except ftplib.all_errors as exp:
1582-
exc = URLError('ftp error: %r' % exp)
1583-
raise exc.with_traceback(sys.exc_info()[2])
1582+
raise URLError(exp) from exp
15841583

15851584
def connect_ftp(self, user, passwd, host, port, dirs, timeout):
15861585
return ftpwrapper(user, passwd, host, port, dirs, timeout,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Wrap network errors consistently in urllib FTP support, so the test suite
2+
doesn't fail when a network is available but the public internet is not
3+
reachable.

0 commit comments

Comments
 (0)