Commit Graph

30423 Commits

Author SHA1 Message Date
Victor Stinner 4e356ad183
gh-109974: Fix threading lock_tests race conditions (#110057)
Fix race conditions in test_threading lock tests. Wait until a
condition is met rather than using time.sleep() with a hardcoded
number of seconds.

* Replace sleeping loops with support.sleeping_retry() which raises
  an exception on timeout.
* Add wait_threads_blocked(nthread) which computes a sleep depending
  on the number of threads. Remove _wait() function.
* test_set_and_clear(): use a way longer Event.wait() timeout.
* BarrierTests.test_repr(): wait until the 2 threads are waiting for
  the barrier. Use a way longer timeout for Barrier.wait() timeout.
* test_thread_leak() no longer needs to count
  len(threading.enumerate()): Bunch uses
  threading_helper.wait_threads_exit() internally which does it in
  wait_for_finished().
* Add BaseLockTests.wait_phase() which implements a timeout.
  test_reacquire() and test_recursion_count() use wait_phase().
2023-09-29 02:34:27 +02:00
Victor Stinner 5fdcea7440
gh-109960: Remove test_pty timeout of 10 seconds (#110058)
In 2003, test_pty got a hardcoded timeout of 10 seconds to prevent
hanging on AIX & HPUX "if run after test_openpty":
commit 7d8145268e. Since 2003, test_pty
was no longer reported to hang on AIX. But today, the test can fail
simply because a CI is busy running other tests in parallel.
The timeout of 10 seconds is no longer needed, just remove it.
Moreover, regrtest now has multiple built-in generic timeout
mecanisms.
2023-09-29 00:01:24 +00:00
Irit Katriel f580edcc6a
gh-109889: fix compiler's redundant NOP detection to look past NOPs with no lineno when looking for the next instruction's lineno (#109987) 2023-09-28 20:33:28 +01:00
Davide Rizzo b14f0ab51c
gh-110038: KqueueSelector must count all read/write events (#110039) 2023-09-28 17:25:10 +00:00
Victor Stinner 7e0fbf5175
gh-110033: Fix signal test_interprocess_signal() (#110035)
Fix test_interprocess_signal() of test_signal. Make sure that the
subprocess.Popen object is deleted before the test raising an
exception in a signal handler. Otherwise, Popen.__del__() can get the
exception which is logged as "Exception ignored in: ...." and the
test fails.
2023-09-28 19:12:11 +02:00
Victor Stinner 757cbd4f29
gh-109972: Enhance test_gdb (#110026)
* Split test_pycfunction.py: add test_cfunction_full.py.
  Split the function into the following 6 functions. In verbose
  mode, these "pycfunction" tests now log each tested call.

  * test_pycfunction_noargs()
  * test_pycfunction_o()
  * test_pycfunction_varargs()
  * test_pycfunction_varargs_keywords()
  * test_pycfunction_fastcall()
  * test_pycfunction_fastcall_keywords()

* Move get_gdb_repr() to PrettyPrintTests.
* Replace DebuggerTests.get_sample_script() with SAMPLE_SCRIPT.
* Rename checkout_hook_path to CHECKOUT_HOOK_PATH.
* Rename gdb_version to GDB_VERSION_TEXT.
* Replace (gdb_major_version, gdb_minor_version) with GDB_VERSION.
* run_gdb() uses "backslashreplace" error handler instead of "replace".
* Add check_gdb() function to util.py.
* Enhance support.check_cflags_pgo(): check also for sysconfig
  PGO_PROF_USE_FLAG (if available) in compiler flags.
* Move some SkipTest checks to test_gdb/__init__.py.
* Elaborate why gdb cannot be tested on Windows: gdb doesn't support
  PDB debug symbol files.
2023-09-28 17:04:01 +00:00
Victor Stinner 9be283e5e1
gh-109594: Fix concurrent.futures test_timeout() (#110018)
Fix test_timeout() of test_concurrent_futures.test_wait. Remove the
future which may or may not complete depending if it takes longer
than the timeout ot not. Keep the second future which does not
complete before wait(). Make also the test faster: 0.5 second instead
of 6 seconds, so remove @support.requires_resource('walltime')
decorator.
2023-09-28 15:21:15 +02:00
Victor Stinner 8f324b7ecd
gh-109972: Split test_gdb.py into test_gdb package (#109977)
Split test_gdb.py file into a test_gdb package made of multiple
tests, so tests can now be run in parallel.

* Create Lib/test/test_gdb/ directory.
* Split test_gdb.py into multiple files in Lib/test/test_gdb/
  directory.
* Move Lib/test/gdb_sample.py to Lib/test/test_gdb/ directory.
  Update get_sample_script(): use __file__ to locate gdb_sample.py.
* Move gdb_has_frame_select() and HAS_PYUP_PYDOWN to test_misc.py.
* Explicitly skip test_gdb on Windows. Previously, test_gdb was
  skipped even if gdb was available because of
  gdb_has_frame_select().
2023-09-28 11:24:15 +00:00
Nikita Sobolev f65f9e80fe
gh-109818: `reprlib.recursive_repr` copies `__type_params__` (#109819) 2023-09-27 19:26:42 -07:00
Eric Snow 32466c97c0
gh-109793: Allow Switching Interpreters During Finalization (gh-109794)
Essentially, we should check the thread ID rather than the thread state pointer.
2023-09-27 13:41:06 -06:00
Dale Collison 74723e1110
gh-109461: Update logging module lock to use context manager (#109462)
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-27 18:26:41 +02:00
Victor Stinner cc54bcf17b
gh-109615: Fix support test_copy_python_src_ignore() on WASM (#109970)
Not only check if src_dir exists, but look also for Lib/os.py
landmark.
2023-09-27 17:29:20 +02:00
Sam Gross 773614e03a
gh-109740: Use 't' in `--disable-gil` SOABI (#109922)
Shared libraries for CPython 3.13 are now marked with a 't' for
threading. For example, `binascii.cpython-313t-darwin.so`.
2023-09-27 15:24:12 +00:00
Victor Stinner 62881a79a8
gh-109566: regrtest doesn't enable --rerun if --python is used (#109969)
regrtest: --fast-ci and --slow-ci options no longer enable --rerun if
the --python option is used.
2023-09-27 16:09:23 +02:00
Irit Katriel ea285ad8b6
gh-109923: set line number on the POP_TOP that follows a RETURN_GENERATOR (#109924) 2023-09-27 13:24:33 +01:00
Victor Stinner b89ed9df39
gh-109615: Fix support test_copy_python_src_ignore() (#109958)
Fix the test when run on an installed Python: use "abs_srcdir" of
sysconfig, and skip the test if the Python source code cannot be
found.

* Tools/patchcheck/patchcheck.py, Tools/freeze/test/freeze.py and
  Lib/test/libregrtest/utils.py now first try to get "abs_srcdir"
  from sysconfig, before getting "srcdir" from sysconfig.
* test.pythoninfo logs sysconfig "abs_srcdir".
2023-09-27 12:32:12 +02:00
Victor Stinner 91fb8daa24
gh-109566: Fix regrtest Python options for WASM/WASI (#109954)
WASM and WASI buildbots use multiple PYTHON environment variables
such as PYTHONPATH and _PYTHON_HOSTRUNNER. Don't use -E if the
--python=COMMAND option is used.
2023-09-27 12:01:16 +02:00
Victor Stinner b1aebf1e65
gh-109565: Fix concurrent.futures test_future_times_out() (#109949)
as_completed() uses a timeout of 100 ms instead of 10 ms. Windows
monotonic clock resolution is around 15.6 ms.
2023-09-27 08:51:44 +00:00
Victor Stinner 1512d6c6ee
gh-109615: Fix test_tools.test_freeze SRCDIR (#109935)
Fix copy_source_tree() function of test_tools.test_freeze:

* Don't copy SRC_DIR/build/ anymore. This directory is modified by
  other tests running in parallel.
* Add test.support.copy_python_src_ignore().
* Use sysconfig to get the source directory.
* Use sysconfig.get_config_var() to get CONFIG_ARGS variable.
2023-09-27 08:18:39 +00:00
Victor Stinner 9dbfe2dc8e
gh-107888: Fix test_mmap.test_access_parameter() on macOS 14 (#109928) 2023-09-27 00:26:34 +02:00
Victor Stinner 9abba715e3
gh-109566: Fix regrtest code adding Python options (#109926)
* On Windows, use subprocess.run() instead of os.execv().
* Only add needed options
* Rename reexec parameter to _add_python_opts.
* Rename --no-reexec option to --dont-add-python-opts.
2023-09-26 21:59:11 +00:00
Serhiy Storchaka 2ef2fffe3b
gh-109845: Make test_ftplib more stable under load (GH-109912)
recv() can return partial data cut in the middle of a multibyte
character. Test raw binary data instead of data incorrectly decoded by parts.
2023-09-26 22:58:46 +03:00
Victor Stinner b1e4f6e83e
gh-109276, gh-109508: Fix libregrtest stdout (#109903)
Remove replace_stdout(): call sys.stdout.reconfigure() instead of set
the error handler to backslashreplace.

display_header() logs an empty line and flush stdout.

Remove encoding workaround in display_header() since stdout error
handler is now set to backslashreplace earlier.
2023-09-26 21:34:50 +02:00
Victor Stinner fbfec5642e
gh-109566: regrtest reexecutes the process (#109909)
When --fast-ci or --slow-ci option is used, regrtest now replaces the
current process with a new process to add "-u -W default -bb -E"
options to Python.

Changes:

* PCbuild/rt.bat and Tools/scripts/run_tests.py no longer need to add
  "-u -W default -bb -E" options to Python: it's now done by
  regrtest.
* Fix Tools/scripts/run_tests.py: flush stdout before replacing the
  process. Previously, buffered messages were lost.
2023-09-26 20:46:52 +02:00
Barney Gale ecd813f054
GH-109187: Improve symlink loop handling in `pathlib.Path.resolve()` (GH-109192)
Treat symlink loops like other errors: in strict mode, raise `OSError`, and
in non-strict mode, do not raise any exception.
2023-09-26 17:57:17 +01:00
Victor Stinner 859618c8cd
gh-109566, regrtest: Add --fast-ci and --slow-ci options (#109570)
* Add --fast-ci and --slow-ci options to libregrtest:

  * --fast-ci uses a default timeout of 10 minutes and "-u all,-cpu"
    (skip slowest tests).
  * --slow-ci uses a default timeout of 20 minues and "-u all" (run
    all tests).

* regrtest header now lists test resources.
* Makefile changes:

  * "make test", "make hostrunnertest" and "make coverage-report" now
    use --fast-ci option and TESTTIMEOUT variable.
  * "make buildbottest" now uses "--slow-ci". Remove options which
    became redundant with "--slow-ci".
  * "make testall" and "make testuniversal" now use --slow-ci option
    and TESTTIMEOUT variable.
  * "make testall" now uses "find -exec rm ..." instead of
    "find ... -print|xargs rm ...", same as "make clean".

* GitHub Actions workflow:

  * Ubuntu and Address Sanitizer jobs now use "make test". Remove
    options which became redundant with "--fast-ci".
  * Windows jobs now use --fast-ci option.
  * Use -j0 to detect the number of CPUs.

* Set Makefile TESTTIMEOUT default to an empty string, since
  --slow-ci and --fast-ci use different default timeout. It's now
  accepted to pass "--timeout=" to regrtest: treated as not timeout.
* Tools/scripts/run_tests.py now uses --fast-ci option.
* Tools/buildbot/test.bat now uses --slow-ci option. Remove
  --timeout=1200 option, redundant with --slow-ci.
2023-09-26 17:22:50 +02:00
Antoine Pitrou 0eb98837b6
gh-109593: Fix reentrancy issue in multiprocessing resource_tracker (#109629)
---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-09-26 13:57:25 +02:00
Victor Stinner 2897142d2e
gh-109832: concurrent.futures test_deadlock restores sys.stderr (#109887)
test_error_at_task_unpickle() and
test_error_during_result_unpickle_in_result_handler() now restore
sys.stderr which is overriden by _raise_error_ignore_stderr().
2023-09-26 12:43:45 +02:00
Victor Stinner 4091deba88
gh-109739: regrtest disables load tracker if refleak (#109871)
regrtest: Fix reference leak check on Windows. Disable the load
tracker on Windows in the reference leak check mode (-R option).
2023-09-26 01:05:07 +00:00
Victor Stinner e5186c3de4
gh-109401: Fix threading barrier test_default_timeout() (#109875)
Increase timeouts. Barrier default timeout should be long enough to
spawn 4 threads on a slow CI.
2023-09-26 00:07:12 +00:00
Jason R. Coombs e9791ba351
gh-88233: zipfile: refactor _strip_extra (#102084)
* Refactor zipfile._strip_extra to use higher level abstractions for extras instead of a heavy-state loop.

* Add blurb

* Remove _strip_extra and use _Extra.strip directly.

* Use memoryview to avoid unnecessary copies while splitting Extras.
2023-09-25 19:46:58 -04:00
Victor Stinner 25bb266fc8
gh-109748: Fix venv test_zippath_from_non_installed_posix() (#109872)
Fix test_zippath_from_non_installed_posix() of test_venv: don't copy
__pycache__/ sub-directories, because they can be modified by other
Python tests running in parallel.
2023-09-25 23:16:30 +00:00
Irit Katriel d73c12b88c
gh-109823: Adjust labels in compiler when removing an empty basic block which is a jump target (#109839) 2023-09-25 18:25:05 +00:00
Antoine Pitrou 88a6137cdb
gh-109599: Add types.CapsuleType (#109600)
---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-09-25 19:50:39 +02:00
Victor Stinner bc06743533
gh-89363: Skip threading test_is_alive_after_fork() if ASAN (#109835)
Skip test_is_alive_after_fork() of test_threading if Python is built
with Address Sanitizer (ASAN).
2023-09-25 16:02:04 +00:00
Victor Stinner 72fb39c965
gh-109276: regrtest re-runs "env changed" tests (#109831)
When a test fails with "env changed" and --rerun option is used, the
test is now re-run in verbose mode in a fresh process.
2023-09-25 16:21:01 +02:00
Victor Stinner faebed4a67
gh-109276: Enhance libregrtest results (#109828)
* Factorize code listing "bad / env changed / ..." tests.
* Add TestResults.is_all_good() method.
* Move "All 400 tests OK." to the end
* Move "Test suite interrupted by signal SIGINT." to the end.
2023-09-25 13:50:15 +00:00
Victor Stinner f29bc9c9a0
gh-109833: Fix asyncio test_wait_for() (#109834)
Expect the test to be "short" but don't measure the exact performance
of the CI. SHORT_TIMEOUT is about 30 seconds whereas the cancelled
coroutine takes around 1 hour.
2023-09-25 13:27:36 +00:00
Alex Waygood 19601efa36
gh-109653: Remove unused imports in the `Lib/` directory (#109803) 2023-09-24 15:07:23 +01:00
Alex Waygood e8be0c9c5a
gh-109653: `typing.py`: improve import time by creating soft-deprecated members on demand (#109651)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
2023-09-23 08:46:35 +01:00
Nikita Sobolev 0d20fc7477
gh-109505: Remove unnecessary `hasattr` checks from `test_asyncio` (#109506) 2023-09-22 21:14:15 -07:00
Victor Stinner b03a791497
gh-109706: Fix multiprocessing test_nested_startmethod() (#109707)
Don't check order, queue items can be written in any order.
2023-09-22 23:49:32 +02:00
Nikita Sobolev 8ded34a1ff
gh-109721: Guard `_testinternalcapi` imports in tests (GH-109722) 2023-09-22 13:51:58 -07:00
Pablo Galindo Salgado b28ffaa193
gh-109596: Ensure repeated rules in the grammar are not allowed and fix incorrect soft keywords (#109606) 2023-09-22 19:03:23 +01:00
Irit Katriel 7c55399172
gh-109719: Fix missing jump target labels when compiler reorders cold/warm blocks (#109734) 2023-09-22 16:59:35 +00:00
Victor Stinner cbbdf2c144
gh-109709: Fix asyncio test_stdin_broken_pipe() (#109710)
Replace harcoded sleep of 500 ms with synchronization using a pipe.

Fix also Process._feed_stdin(): catch also BrokenPipeError on
stdin.write(input), not only on stdin.drain().
2023-09-22 15:29:42 +02:00
elfstrom 405b06375a
gh-105829: Fix concurrent.futures.ProcessPoolExecutor deadlock (#108513)
This fixes issue #105829, https://github.com/python/cpython/issues/105829

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Antoine Pitrou <antoine@python.org>
Co-authored-by: Chris Withers <chris@withers.org>
Co-authored-by: Thomas Moreau <thomas.moreau.2010@gmail.com>
2023-09-22 13:55:56 +01:00
EliseevEgor 8fc071345b
gh-106584: Fix exit code for unittest in Python 3.12 (#106588)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-09-22 14:26:27 +02:00
Victor Stinner 1eb1b45183
gh-109702: Increase concurrent_futures deadlock timeout (#109703)
Replace SHORT_TIMEOUT with LONG_TIMEOUT in test_deadlock of
test_concurrent_futures.
2023-09-22 03:13:31 +02:00
AN Long 4230d7ce93
gh-108996: fix and enable test_msvcrt (#109226)
* Add _testconsole.flush_console_input_buffer() function.
* test_kbhit(), test_getwch() and test_getwche() now call
  flush_console_input_buffer().
* Don't override sys.stdin anymore (not needed).
2023-09-22 02:19:48 +02:00