Skip to content

test.test_urllib2.HandlerTests.test_ftp_error fails without network access (running -u-network) #125584

@mgorny

Description

@mgorny

Bug report

Bug description:

The newly added test_ftp_error (in 77133f5, FWICS) is failing in environments without Internet access, even though it is not marked as needing the "network" resource:

======================================================================
FAIL: test_ftp_error (test.test_urllib2.HandlerTests.test_ftp_error)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/tmp/portage/dev-lang/python-3.14.0_alpha1/work/Python-3.14.0a1/Lib/urllib/request.py", line 1531, in ftp_open
    host = socket.gethostbyname(host)
socket.gaierror: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/tmp/portage/dev-lang/python-3.14.0_alpha1/work/Python-3.14.0a1/Lib/test/test_urllib2.py", line 811, in test_ftp_error
    urlopen("ftp://www.pythontest.net/")
    ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/tmp/portage/dev-lang/python-3.14.0_alpha1/work/Python-3.14.0a1/Lib/urllib/request.py", line 489, in open
    response = self._open(req, data)
  File "/var/tmp/portage/dev-lang/python-3.14.0_alpha1/work/Python-3.14.0a1/Lib/urllib/request.py", line 506, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
                              '_open', req)
  File "/var/tmp/portage/dev-lang/python-3.14.0_alpha1/work/Python-3.14.0a1/Lib/urllib/request.py", line 466, in _call_chain
    result = func(*args)
  File "/var/tmp/portage/dev-lang/python-3.14.0_alpha1/work/Python-3.14.0a1/Lib/urllib/request.py", line 1533, in ftp_open
    raise URLError(msg)
urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name resolution>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/tmp/portage/dev-lang/python-3.14.0_alpha1/work/Python-3.14.0a1/Lib/test/test_urllib2.py", line 813, in test_ftp_error
    self.assertEqual(raised.reason,
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
                     f"ftp error: {exception.args[0]}")
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: gaierror(-3, 'Temporary failure in name resolution') != 'ftp error: 500 OOPS: cannot change directory:/nonexistent'

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions