Skip to content

test.support.socket_helper fails to handle test_urllib2net.TimeoutTest exception #122967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
encukou opened this issue Aug 13, 2024 · 1 comment
Closed
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@encukou
Copy link
Member

encukou commented Aug 13, 2024

Recent buildbot runs like bigmem or Fedora show this in test_urllib2net.TimeoutTest:

  • ftplib raises its TimeoutError (error_temp: 421 Timeout -- temp because FTP 4xx is ”Transient [=temporary] Negative Completion reply”)
  • urllib wraps it in urllib.error.URLError
  • test.support.socket_helper assumes the error's reason is a string, put it's a error_temp object.
======================================================================
ERROR: test_ftp_no_timeout (test.test_urllib2net.TimeoutTest.test_ftp_no_timeout)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\urllib\request.py", line 1548, in ftp_open
    fp, retrlen = fw.retrfile(file, type)
                  ~~~~~~~~~~~^^^^^^^^^^^^
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\urllib\request.py", line 2443, in retrfile
    conn, retrlen = self.ftp.ntransfercmd(cmd)
                    ~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\ftplib.py", line 353, in ntransfercmd
    host, port = self.makepasv()
                 ~~~~~~~~~~~~~^^
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\ftplib.py", line 327, in makepasv
    untrusted_host, port = parse227(self.sendcmd('PASV'))
                                    ~~~~~~~~~~~~^^^^^^^^
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\ftplib.py", line 281, in sendcmd
    return self.getresp()
           ~~~~~~~~~~~~^^
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\ftplib.py", line 252, in getresp
    raise error_temp(resp)
ftplib.error_temp: 421 Timeout.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\test\support\socket_helper.py", line 249, in transient_internet
    yield
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\test\test_urllib2net.py", line 364, in test_ftp_no_timeout
    u = _urlopen_with_retry(self.FTP_HOST, timeout=None)
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\test\test_urllib2net.py", line 29, in wrapped
    return _retry_thrice(func, exc, *args, **kwargs)
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\test\test_urllib2net.py", line 25, in _retry_thrice
    raise last_exc
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\test\test_urllib2net.py", line 21, in _retry_thrice
    return func(*args, **kwargs)
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\urllib\request.py", line 189, in urlopen
    return opener.open(url, data, timeout)
           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\urllib\request.py", line 489, in open
    response = self._open(req, data)
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\urllib\request.py", line 506, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
                              '_open', req)
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\urllib\request.py", line 466, in _call_chain
    result = func(*args)
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\urllib\request.py", line 1558, in ftp_open
    raise URLError(exp) from exp
urllib.error.URLError: <urlopen error 421 Timeout.>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\test\test_urllib2net.py", line 361, in test_ftp_no_timeout
    with socket_helper.transient_internet(self.FTP_HOST):
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\contextlib.py", line 162, in __exit__
    self.gen.throw(value)
    ~~~~~~~~~~~~~~^^^^^^^
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\test\support\socket_helper.py", line 264, in transient_internet
    filter_error(err)
    ~~~~~~~~~~~~^^^^^
  File "R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\test\support\socket_helper.py", line 237, in filter_error
    (("ConnectionRefusedError" in err.reason) or
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'error_temp' is not a container or iterable
@picnixz picnixz added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir labels Aug 13, 2024
@encukou
Copy link
Member Author

encukou commented Aug 14, 2024

#122999 has more info, closing this as duplicate

@encukou encukou closed this as completed Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants