python / python/cpython

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

Abierto
#140,029 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

OS-mac tests type-bug
Lenguaje dominante
Python
Estrellas
77.2k
Forks
35.9k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con las pruebas mencionadas test_urllib2_localnet y test_urllib2net; después, inspecciona cómo las pruebas de urllib configuran no_proxy y obtienen los proxies del sistema en macOS. Reproduce el problema con un proxy del sistema en macOS y ejecuta las pruebas de urllib indicadas; el trabajo estará terminado cuando estas pruebas pasen sin fallos relacionados con el proxy.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
networking
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.