python / python/cpython

some tests will fail on macOS when have a system proxy such as test_urllib2_localnet test_urllib2net

Open
#140,029 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

OS-mac tests type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

reproduce

make macOS a system proxy(not http_proxy https_proxy in env but at system)

➜  cpython git:(main) echo $http_proxy

➜  cpython git:(main) ./python.exe -c 'import urllib.request;print(urllib.request.getproxies())'
{'http': 'http://127.0.0.1:7897', 'https': 'http://127.0.0.1:7897', 'socks': 'http://127.0.0.1:7897'}

some of the error is because we only add no_proxy for env(in tests)
but macOS maybe have a system one

some bt

Ran 2 tests in 1.697s

FAILED (errors=2)
Warning -- Unraisable exception
Exception ignored while finalizing socket <socket.socket [closed] fd=3, family=2, type=1, proto=6>:
Traceback (most recent call last):
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 165, in _load_run_test
    regrtest_runner(result, test_func, runtests)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 118, in regrtest_runner
    test_result = test_func()
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 162, in test_func
    return run_unittest(test_mod, runtests)
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 42, in run_unittest
    return _run_suite(tests)
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 105, in _run_suite
    raise support.TestFailedWithDetails(err, errors, failures, stats=stats)
test.support.TestFailedWithDetails: multiple errors occurred

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/hyi/prs/cpython/Lib/test/support/__init__.py", line 847, in gc_collect
    gc.collect()
    ~~~~~~~~~~^^
ResourceWarning: unclosed <socket.socket [closed] fd=3, family=2, type=1, proto=6>
Warning -- Unraisable exception
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x105d07950>:
Traceback (most recent call last):
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 165, in _load_run_test
    regrtest_runner(result, test_func, runtests)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 118, in regrtest_runner
    test_result = test_func()
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 162, in test_func
    return run_unittest(test_mod, runtests)
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 42, in run_unittest
    return _run_suite(tests)
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 105, in _run_suite
    raise support.TestFailedWithDetails(err, errors, failures, stats=stats)
test.support.TestFailedWithDetails: multiple errors occurred

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/hyi/prs/cpython/Lib/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ResourceWarning: Implicitly cleaning up <HTTPError 404: 'Not Found'>
Warning -- Unraisable exception
Exception ignored while finalizing socket <socket.socket [closed] fd=4, family=2, type=1, proto=6>:
Traceback (most recent call last):
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 165, in _load_run_test
    regrtest_runner(result, test_func, runtests)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 118, in regrtest_runner
    test_result = test_func()
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 162, in test_func
    return run_unittest(test_mod, runtests)
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 42, in run_unittest
    return _run_suite(tests)
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 105, in _run_suite
    raise support.TestFailedWithDetails(err, errors, failures, stats=stats)
test.support.TestFailedWithDetails: multiple errors occurred

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/hyi/prs/cpython/Lib/test/support/__init__.py", line 847, in gc_collect
    gc.collect()
    ~~~~~~~~~~^^
ResourceWarning: unclosed <socket.socket [closed] fd=4, family=2, type=1, proto=6>
Warning -- Unraisable exception
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x105d07950>:
Traceback (most recent call last):
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 165, in _load_run_test
    regrtest_runner(result, test_func, runtests)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 118, in regrtest_runner
    test_result = test_func()
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 162, in test_func
    return run_unittest(test_mod, runtests)
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 42, in run_unittest
    return _run_suite(tests)
  File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 105, in _run_suite
    raise support.TestFailedWithDetails(err, errors, failures, stats=stats)
test.support.TestFailedWithDetails: multiple errors occurred

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/hyi/prs/cpython/Lib/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ResourceWarning: Implicitly cleaning up <HTTPError 404: 'Not Found'>
test test_urllib2net failed
0:02:07 load avg: 8.33 [5/5/5] test_urllibnet failed (env changed)
Re-running test_urllibnet in verbose mode
testURLread (test.test_urllibnet.URLTimeoutTest.testURLread) ... ok
test_bad_address (test.test_urllibnet.urlopenNetworkTests.test_bad_address) ... Warning -- Unraisable exception
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x1030bb950>:
Traceback (most recent call last):
  File "/Users/hyi/prs/cpython/Lib/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ResourceWarning: Implicitly cleaning up <HTTPError 502: 'Bad Gateway'>
ok
test_basic (test.test_urllibnet.urlopenNetworkTests.test_basic) ... ok
test_getcode (test.test_urllibnet.urlopenNetworkTests.test_getcode) ... ok
test_geturl (test.test_urllibnet.urlopenNetworkTests.test_geturl) ... ok
test_info (test.test_urllibnet.urlopenNetworkTests.test_info) ... ok
test_readlines (test.test_urllibnet.urlopenNetworkTests.test_readlines) ... ok
test_basic (test.test_urllibnet.urlretrieveNetworkTests.test_basic) ... ok
test_data_header (test.test_urllibnet.urlretrieveNetworkTests.test_data_header) ... ok
test_header (test.test_urllibnet.urlretrieveNetworkTests.test_header) ... ok
test_reporthook (test.test_urllibnet.urlretrieveNetworkTests.test_reporthook) ... ok
test_specified_path (test.test_urllibnet.urlretrieveNetworkTests.test_specified_path) ... ok

----------------------------------------------------------------------
Ran 12 tests in 7.103s

OK
4 tests failed again:
    test_urllib test_urllib2 test_urllib2_localnet test_urllib2net

== Tests result: FAILURE then FAILURE ==

10 slowest tests:
- test_smtpnet: 1 min 10 sec
- test_signal: 48.5 sec
- test.test_multiprocessing_spawn.test_processes: 30.4 sec
- test.test_multiprocessing_forkserver.test_processes: 29.7 sec
- test_socket: 29.1 sec
- test_urllib2net: 28.4 sec
- test_xmlrpc: 27.3 sec
- test.test_concurrent_futures.test_process_pool: 26.3 sec
- test_logging: 25.0 sec
- test.test_io.test_signals: 24.4 sec

31 tests skipped:
    test.test_asyncio.test_windows_events
    test.test_asyncio.test_windows_utils test.test_gdb.test_backtrace
    test.test_gdb.test_cfunction test.test_gdb.test_cfunction_full
    test.test_gdb.test_misc test.test_gdb.test_pretty_print
    test.test_multiprocessing_fork.test_manager
    test.test_multiprocessing_fork.test_misc
    test.test_multiprocessing_fork.test_processes
    test.test_multiprocessing_fork.test_threads
    test.test_os.test_windows test_android test_dbm_gnu test_devpoll
    test_epoll test_free_threading test_idle test_launcher test_msvcrt
    test_startfile test_tcl test_tkinter test_ttk test_ttk_textonly
    test_turtle test_winapi test_winconsoleio test_winreg
    test_winsound test_wmi

2 tests skipped (resource denied):
    test_peg_generator test_zipfile64

1 test altered the execution environment (env changed):
    test_urllibnet

5 re-run tests:
    test_urllib test_urllib2 test_urllib2_localnet test_urllib2net
    test_urllibnet

4 tests failed:
    test_urllib test_urllib2 test_urllib2_localnet test_urllib2net
CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs
  • gh-140144

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the named tests test_urllib2_localnet and test_urllib2net, then inspect how the urllib tests configure no_proxy and obtain system proxies on macOS. Reproduce with a macOS system proxy and run the listed urllib tests; done means these tests pass without proxy-related failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.