You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's a raw log of an example failure below. The problem is that ftp_open passes an exception object to URLError() when it should pass a string describing the error.
2024-08-07T17:16:46.3124967Z ======================================================================
2024-08-07T17:16:46.3126394Z ERROR: test_ftp (test.test_urllib2net.OtherNetworkTests.test_ftp) (url='ftp://www.pythontest.net/README')
2024-08-07T17:16:46.3127731Z ----------------------------------------------------------------------
2024-08-07T17:16:46.3128700Z Traceback (most recent call last):
2024-08-07T17:16:46.3129959Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 1541, in ftp_open
2024-08-07T17:16:46.3131290Z fw = self.connect_ftp(user, passwd, host, port, dirs, req.timeout)
2024-08-07T17:16:46.3133275Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 1585, in connect_ftp
2024-08-07T17:16:46.3134619Z self.cache[key] = ftpwrapper(user, passwd, host, port,
2024-08-07T17:16:46.3135409Z ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-07T17:16:46.3136086Z dirs, timeout)
2024-08-07T17:16:46.3136735Z ^^^^^^^^^^^^^^
2024-08-07T17:16:46.3138015Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 2394, in init
2024-08-07T17:16:46.3139073Z self.init()
2024-08-07T17:16:46.3139474Z ~~~~~~~~~^^
2024-08-07T17:16:46.3140512Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 2404, in init
2024-08-07T17:16:46.3141625Z self.ftp.login(self.user, self.passwd)
2024-08-07T17:16:46.3142262Z ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-07T17:16:46.3143380Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/ftplib.py", line 414, in login
2024-08-07T17:16:46.3144486Z resp = self.sendcmd('PASS ' + passwd)
2024-08-07T17:16:46.3145655Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/ftplib.py", line 281, in sendcmd
2024-08-07T17:16:46.3146651Z return self.getresp()
2024-08-07T17:16:46.3147132Z ~~~~~~~~~~~~^^
2024-08-07T17:16:46.3148166Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/ftplib.py", line 254, in getresp
2024-08-07T17:16:46.3149173Z raise error_perm(resp)
2024-08-07T17:16:46.3149923Z ftplib.error_perm: 500 OOPS: cannot change directory:/nonexistent
2024-08-07T17:16:46.3150523Z
2024-08-07T17:16:46.3150989Z The above exception was the direct cause of the following exception:
2024-08-07T17:16:46.3151632Z
2024-08-07T17:16:46.3151862Z Traceback (most recent call last):
2024-08-07T17:16:46.3153340Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/support/socket_helper.py", line 249, in transient_internet
2024-08-07T17:16:46.3154580Z yield
2024-08-07T17:16:46.3155723Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_urllib2net.py", line 261, in _test_urls
2024-08-07T17:16:46.3156974Z f = urlopen(url, req, support.INTERNET_TIMEOUT)
2024-08-07T17:16:46.3158337Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_urllib2net.py", line 29, in wrapped
2024-08-07T17:16:46.3159556Z return _retry_thrice(func, exc, *args, **kwargs)
2024-08-07T17:16:46.3160983Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_urllib2net.py", line 25, in _retry_thrice
2024-08-07T17:16:46.3162134Z raise last_exc
2024-08-07T17:16:46.3163329Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_urllib2net.py", line 21, in _retry_thrice
2024-08-07T17:16:46.3164734Z return func(*args, **kwargs)
2024-08-07T17:16:46.3165888Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 489, in open
2024-08-07T17:16:46.3166946Z response = self._open(req, data)
2024-08-07T17:16:46.3168424Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 506, in _open
2024-08-07T17:16:46.3169693Z result = self._call_chain(self.handle_open, protocol, protocol +
2024-08-07T17:16:46.3170584Z '_open', req)
2024-08-07T17:16:46.3171860Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 466, in _call_chain
2024-08-07T17:16:46.3172951Z result = func(*args)
2024-08-07T17:16:46.3174102Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 1558, in ftp_open
2024-08-07T17:16:46.3175195Z raise URLError(exp) from exp
2024-08-07T17:16:46.3176154Z urllib.error.URLError: <urlopen error 500 OOPS: cannot change directory:/nonexistent>
2024-08-07T17:16:46.3176931Z
2024-08-07T17:16:46.3177384Z During handling of the above exception, another exception occurred:
2024-08-07T17:16:46.3178025Z
2024-08-07T17:16:46.3178249Z Traceback (most recent call last):
2024-08-07T17:16:46.3179836Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_urllib2net.py", line 259, in _test_urls
2024-08-07T17:16:46.3181178Z with socket_helper.transient_internet(url):
2024-08-07T17:16:46.3181912Z ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
2024-08-07T17:16:46.3183252Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/contextlib.py", line 162, in exit
2024-08-07T17:16:46.3184362Z self.gen.throw(value)
2024-08-07T17:16:46.3184879Z ~~~~~~~~~~~~~~^^^^^^^
2024-08-07T17:16:46.3186366Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/support/socket_helper.py", line 264, in transient_internet
2024-08-07T17:16:46.3187719Z filter_error(err)
2024-08-07T17:16:46.3188195Z ~~~~~~~~~~~~^^^^^
2024-08-07T17:16:46.3189586Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/support/socket_helper.py", line 237, in filter_error
2024-08-07T17:16:46.3190947Z (("ConnectionRefusedError" in err.reason) or
2024-08-07T17:16:46.3191673Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-07T17:16:46.3192728Z TypeError: argument of type 'error_perm' is not a container or iterable
* pass the original string error message from the ftplib error to URLError()
* Update request.py
Change error string for ftp error to be consistent with other errors reported for ftp
* Add NEWS entry for change to urllib.request for ftp errors.
* Track the change in the ftp error message in the test.
thanks Jeremy! closing as at a glance I believe that merged PR addresses the issue? reopen if not. it's a very minor behavior change so I wouldn't backport it to bugfix releases. Ping Thomas if you want to have it in 3.13, it'd likely be fine there.
Yes. The issue should be resolved, and I think it's a small enough change that there's no need to backport. I'm going to do another pass through the code and see if we should change all the exceptions to have string arguments, but that's not specifically related to this issue.
blhsing
pushed a commit
to blhsing/cpython
that referenced
this issue
Aug 22, 2024
…on#122913)
* pass the original string error message from the ftplib error to URLError()
* Update request.py
Change error string for ftp error to be consistent with other errors reported for ftp
* Add NEWS entry for change to urllib.request for ftp errors.
* Track the change in the ftp error message in the test.
Bug report
Bug description:
There's a raw log of an example failure below. The problem is that ftp_open passes an exception object to URLError() when it should pass a string describing the error.
2024-08-07T17:16:46.3124967Z ======================================================================
2024-08-07T17:16:46.3126394Z ERROR: test_ftp (test.test_urllib2net.OtherNetworkTests.test_ftp) (url='ftp://www.pythontest.net/README')
2024-08-07T17:16:46.3127731Z ----------------------------------------------------------------------
2024-08-07T17:16:46.3128700Z Traceback (most recent call last):
2024-08-07T17:16:46.3129959Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 1541, in ftp_open
2024-08-07T17:16:46.3131290Z fw = self.connect_ftp(user, passwd, host, port, dirs, req.timeout)
2024-08-07T17:16:46.3133275Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 1585, in connect_ftp
2024-08-07T17:16:46.3134619Z self.cache[key] = ftpwrapper(user, passwd, host, port,
2024-08-07T17:16:46.3135409Z ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-07T17:16:46.3136086Z dirs, timeout)
2024-08-07T17:16:46.3136735Z ^^^^^^^^^^^^^^
2024-08-07T17:16:46.3138015Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 2394, in init
2024-08-07T17:16:46.3139073Z self.init()
2024-08-07T17:16:46.3139474Z ~~~~~~~~~^^
2024-08-07T17:16:46.3140512Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 2404, in init
2024-08-07T17:16:46.3141625Z self.ftp.login(self.user, self.passwd)
2024-08-07T17:16:46.3142262Z ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-07T17:16:46.3143380Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/ftplib.py", line 414, in login
2024-08-07T17:16:46.3144486Z resp = self.sendcmd('PASS ' + passwd)
2024-08-07T17:16:46.3145655Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/ftplib.py", line 281, in sendcmd
2024-08-07T17:16:46.3146651Z return self.getresp()
2024-08-07T17:16:46.3147132Z ~~~~~~~~~~~~^^
2024-08-07T17:16:46.3148166Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/ftplib.py", line 254, in getresp
2024-08-07T17:16:46.3149173Z raise error_perm(resp)
2024-08-07T17:16:46.3149923Z ftplib.error_perm: 500 OOPS: cannot change directory:/nonexistent
2024-08-07T17:16:46.3150523Z
2024-08-07T17:16:46.3150989Z The above exception was the direct cause of the following exception:
2024-08-07T17:16:46.3151632Z
2024-08-07T17:16:46.3151862Z Traceback (most recent call last):
2024-08-07T17:16:46.3153340Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/support/socket_helper.py", line 249, in transient_internet
2024-08-07T17:16:46.3154580Z yield
2024-08-07T17:16:46.3155723Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_urllib2net.py", line 261, in _test_urls
2024-08-07T17:16:46.3156974Z f = urlopen(url, req, support.INTERNET_TIMEOUT)
2024-08-07T17:16:46.3158337Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_urllib2net.py", line 29, in wrapped
2024-08-07T17:16:46.3159556Z return _retry_thrice(func, exc, *args, **kwargs)
2024-08-07T17:16:46.3160983Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_urllib2net.py", line 25, in _retry_thrice
2024-08-07T17:16:46.3162134Z raise last_exc
2024-08-07T17:16:46.3163329Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_urllib2net.py", line 21, in _retry_thrice
2024-08-07T17:16:46.3164734Z return func(*args, **kwargs)
2024-08-07T17:16:46.3165888Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 489, in open
2024-08-07T17:16:46.3166946Z response = self._open(req, data)
2024-08-07T17:16:46.3168424Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 506, in _open
2024-08-07T17:16:46.3169693Z result = self._call_chain(self.handle_open, protocol, protocol +
2024-08-07T17:16:46.3170584Z '_open', req)
2024-08-07T17:16:46.3171860Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 466, in _call_chain
2024-08-07T17:16:46.3172951Z result = func(*args)
2024-08-07T17:16:46.3174102Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/urllib/request.py", line 1558, in ftp_open
2024-08-07T17:16:46.3175195Z raise URLError(exp) from exp
2024-08-07T17:16:46.3176154Z urllib.error.URLError: <urlopen error 500 OOPS: cannot change directory:/nonexistent>
2024-08-07T17:16:46.3176931Z
2024-08-07T17:16:46.3177384Z During handling of the above exception, another exception occurred:
2024-08-07T17:16:46.3178025Z
2024-08-07T17:16:46.3178249Z Traceback (most recent call last):
2024-08-07T17:16:46.3179836Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_urllib2net.py", line 259, in _test_urls
2024-08-07T17:16:46.3181178Z with socket_helper.transient_internet(url):
2024-08-07T17:16:46.3181912Z ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
2024-08-07T17:16:46.3183252Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/contextlib.py", line 162, in exit
2024-08-07T17:16:46.3184362Z self.gen.throw(value)
2024-08-07T17:16:46.3184879Z ~~~~~~~~~~~~~~^^^^^^^
2024-08-07T17:16:46.3186366Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/support/socket_helper.py", line 264, in transient_internet
2024-08-07T17:16:46.3187719Z filter_error(err)
2024-08-07T17:16:46.3188195Z ~~~~~~~~~~~~^^^^^
2024-08-07T17:16:46.3189586Z File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/support/socket_helper.py", line 237, in filter_error
2024-08-07T17:16:46.3190947Z (("ConnectionRefusedError" in err.reason) or
2024-08-07T17:16:46.3191673Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-07T17:16:46.3192728Z TypeError: argument of type 'error_perm' is not a container or iterable
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: