Commit graph

119701 commits

Author SHA1 Message Date
Victor Stinner
8939221e91
[3.12] gh-109615: Fix support test_copy_python_src_ignore() (#109958) (#110340)
* 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".

(cherry picked from commit b89ed9df39)

* 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.

(cherry picked from commit cc54bcf17b)

* gh-109615: Look for 'Modules' as landmark for test_copy_python_src_ignore (GH-110108)

(cherry picked from commit 20bc5f7c28)

* gh-109748: Fix again venv test_zippath_from_non_installed_posix() (#110149)

Call also copy_python_src_ignore() on listdir() names.

shutil.copytree(): replace set() with an empty tuple. An empty tuple
becomes a constant in the compiler and checking if an item is in an
empty tuple is cheap.

(cherry picked from commit 0def8c712b)

---------

Co-authored-by: Steve Dower <steve.dower@python.org>
2023-10-04 10:27:12 +00:00
Victor Stinner
e7a61d34b7
[3.12] gh-109972: Split test_gdb.py into test_gdb package (#109977) (#110339)
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().

(cherry picked from commit 8f324b7ecd)
2023-10-04 10:26:24 +00:00
Miss Islington (bot)
35feda5bc9
[3.12] gh-110267: Add tests for pickling and copying PyStructSequence objects (GH-110272) (GH-110285)
(cherry picked from commit 2d4865d775)

Co-authored-by: Xuehai Pan <XuehaiPan@pku.edu.cn>
2023-10-04 12:01:03 +03:00
Miss Islington (bot)
414f562081
[3.12] gh-109917: Fix test instability in test_concurrent_futures (GH-110306) (#110315)
gh-109917: Fix test instability in test_concurrent_futures (GH-110306)

The test had an instability issue due to the ordering of the dummy
queue operation and the real wakeup pipe operations. Both primitives
are thread safe but not done atomically as a single update and may
interleave arbitrarily. With the old order of operations this can lead
to an incorrect state where the dummy queue is full but the wakeup
pipe is empty. By swapping the order in clear() I think this can no
longer happen in any possible operation interleaving (famous last
words).
(cherry picked from commit a376a72bd9)

Co-authored-by: elfstrom <elfstrom@users.noreply.github.com>
2023-10-03 22:28:13 +00:00
Adam Turner
4c0f42bbc6
[3.12] Docs: Avoid the deprecated `.. cmdoption::` directive (GH-110292) (#110302)
[3.12] Docs: Avoid the deprecated ``.. cmdoption::`` directive (GH-110292).
(cherry picked from commit 77e9aae383)
2023-10-03 20:55:29 +03:00
Miss Islington (bot)
90dea557bb
[3.12] gh-109234: Hint to contextlib.closing in sqlite3 context manager docs (GH-109322) (#110294)
(cherry picked from commit 4227bfa8b2)

Co-authored-by: Lincoln <71312724+Lincoln-developer@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-10-03 16:02:44 +00:00
Alex Waygood
4dac406f66
[3.12] Enable ruff on Lib/test/test_typing.py (#110179) (#110288)
Enable ruff on `Lib/test/test_typing.py` (#110179)
2023-10-03 15:13:22 +00:00
Miss Islington (bot)
bd56c51f1c
[3.12] Bump various dependencies in Doc/requirements-oldest-sphinx.txt (GH-110278) (#110280)
Bump various dependencies in `Doc/requirements-oldest-sphinx.txt` (GH-110278)

This resolves a Dependabot security alert on the repository for urllib3==2.0.4.
(cherry picked from commit f1663a492e)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-10-03 13:18:09 +00:00
Miss Islington (bot)
64afbf6f28
[3.12] Fix typo in py312 whatsnew: add missing closing paren (GH-110255) (#110257)
Fix typo in py312 whatsnew: add missing closing paren (GH-110255)
(cherry picked from commit 8c071373f1)

Co-authored-by: Lele Gaifax <lele@metapensiero.it>
2023-10-03 06:20:20 +00:00
Miss Islington (bot)
b0b9b91f78
[3.12] Remove unused Misc/requirements-test.txt (GH-110240) (#110253)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-10-02 23:36:30 -06:00
Miss Islington (bot)
41e8e1553f
[3.12] gh-109653: Reduce the import time of random by 60% (GH-110221) (#110247)
gh-109653: Fix regression in the import time of `random` in Python 3.12 (GH-110221)
(cherry picked from commit 21a6263020)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-10-02 23:31:55 +00:00
Miss Islington (bot)
892b1942a7
[3.12] gh-110241: Add missing error check to record_eval in _testinternalcapi (GH-110242) (#110244)
gh-110241: Add missing error check to `record_eval` in `_testinternalcapi` (GH-110242)
(cherry picked from commit 4596c76d1a)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-10-02 21:38:25 +00:00
Miss Islington (bot)
74d0b60811
[3.12] gh-108494: Document how to add a project in PCbuild/readme.txt (GH-110077) (#110230)
gh-108494: Document how to add a project in PCbuild/readme.txt (GH-110077)

(cherry picked from commit 6387b5313c)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-02 19:48:31 +00:00
Victor Stinner
0745ab88e5
[3.12] gh-110088, gh-109878: Fix test_asyncio timeouts (#110092) (#110098)
gh-110088, gh-109878: Fix test_asyncio timeouts (#110092)

Fix test_asyncio timeouts: don't measure the maximum duration, a test
should not measure a CI performance. Only measure the minimum
duration when a task has a timeout or delay. Add CLOCK_RES to
test_asyncio.utils.

(cherry picked from commit db0a258e79)
2023-10-02 19:35:29 +00:00
Victor Stinner
c188a13c8e
[3.12] gh-110031: Skip test_threading fork tests if ASAN (#110100) (#110103)
gh-110031: Skip test_threading fork tests if ASAN (#110100)

Skip test_threading tests using thread+fork if Python is built with
Address Sanitizer (ASAN).

(cherry picked from commit 86e76ab8af)
2023-10-02 19:31:12 +00:00
Alex Waygood
da75bd6c31
[3.12] gh-109782: Ensure os.path.isdir has the same signature on all platforms (GH-109790) (#110233)
gh-109782: Ensure `os.path.isdir` has the same signature on all platforms (GH-109790)

Co-authored-by: Amin Alaee <mohammadamin.alaee@gmail.com>
2023-10-02 19:25:06 +00:00
Raymond Hettinger
221c8d64e6
[3.12] Sync factor() recipe with main branch (gh-110231) 2023-10-02 14:19:46 -05:00
Alex Waygood
25bf0564c4
[3.12] Fix typos in docs and comments (#109619) (#109621)
Fix typos in docs and comments (#109619)

Co-authored-by: Heinz-Alexander Fuetterer <35225576+afuetterer@users.noreply.github.com>
2023-10-02 17:34:49 +00:00
Miss Islington (bot)
196738fc86
[3.12] Code: Update Donghee Na's name (GH-109744) (#110225)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-10-02 17:31:34 +00:00
Miss Islington (bot)
46e69576a9
[3.12] gh-110178: Use fewer weakrefs in test_typing.py (GH-110194) (#110224)
gh-110178: Use fewer weakrefs in test_typing.py (GH-110194)

Confirmed that without the C changes from GH-108517, this test still segfaults with only 10 weakrefs.
(cherry picked from commit 732ad44cec)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-10-02 18:15:30 +01:00
Miss Islington (bot)
8296b53027
[3.12] 3.12 What's New: Remove duplicate "up to" (GH-110219) (#110220)
3.12 What's New: Remove duplicate "up to" (GH-110219)
(cherry picked from commit 8d92b6eff3)

Co-authored-by: numbermaniac <5206120+numbermaniac@users.noreply.github.com>
2023-10-02 17:48:57 +02:00
Victor Stinner
f911d7ecd9
[3.12] gh-108963: using random to generate unique string in sys.intern test … (#110216)
gh-108963: using random to generate unique string in sys.intern test (#109491)

(cherry picked from commit 44b1e4ea48)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
2023-10-02 17:48:42 +02:00
Miss Islington (bot)
b61a4da459
[3.12] gh-109590: Update shutil.which on Windows to prefer a PATHEXT extension on executable files (GH-109995) (#110202)
gh-109590: Update shutil.which on Windows to prefer a PATHEXT extension on executable files (GH-109995)

The default arguments for shutil.which() request an executable file, but extensionless files are not executable on Windows and should be ignored.
(cherry picked from commit 29b875bb93)

Co-authored-by: Charles Machalow <csm10495@gmail.com>
2023-10-02 17:48:30 +02:00
Miss Islington (bot)
10af2242f4
[3.12] gh-110160: Fix flaky test_find_periodic_pattern in string_tests (GH-110170) (#110182)
gh-110160: Fix flaky `test_find_periodic_pattern` in `string_tests` (GH-110170)
(cherry picked from commit 06faa9a39b)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-10-02 17:48:17 +02:00
Victor Stinner
5245b97e13
[3.12] gh-109649: Enhance os.cpu_count() documentation (#110169)
* gh-109649: Enhance os.cpu_count() documentation

* Doc: Specify that os.cpu_count() counts *logicial* CPUs.
* Doc: Specify that os.sched_getaffinity(0) is related to the calling
  thread.
* Fix test_posix.test_sched_getaffinity(): restore the old CPU mask
  when the test completes!

* Restore removed text
2023-10-02 17:47:57 +02:00
Miss Islington (bot)
ce332aa8c5
[3.12] gh-110088: Fix asyncio test_prompt_cancellation() (GH-110157) (#110158)
gh-110088: Fix asyncio test_prompt_cancellation() (GH-110157)

Don't measure the CI performance: don't test the maximum elapsed
time. The check failed on a slow CI.
(cherry picked from commit c62b49ecc8)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-02 17:47:41 +02:00
Miss Islington (bot)
b8a30a4365
[3.12] Add example for linear_regression() with proportional=True. (gh-110133) (#110134)
Add example for linear_regression() with proportional=True. (gh-110133)
(cherry picked from commit 613c0d4e86)

Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
2023-10-02 17:47:28 +02:00
Victor Stinner
356de021d7
[3.12] gh-109047: concurrent.futures catches RuntimeError (#109810) (#110126)
gh-109047: concurrent.futures catches PythonFinalizationError (#109810)

concurrent.futures: The *executor manager thread* now catches
exceptions when adding an item to the *call queue*. During Python
finalization, creating a new thread can now raise RuntimeError. Catch
the exception and call terminate_broken() in this case.

Add test_python_finalization_error() to test_concurrent_futures.

concurrent.futures._ExecutorManagerThread changes:

* terminate_broken() no longer calls shutdown_workers() since the
  call queue is no longer working anymore (read and write ends of
  the queue pipe are closed).
* terminate_broken() now terminates child processes, not only
  wait until they complete.
* _ExecutorManagerThread.terminate_broken() now holds shutdown_lock
  to prevent race conditons with ProcessPoolExecutor.submit().

multiprocessing.Queue changes:

* Add _terminate_broken() method.
* _start_thread() sets _thread to None on exception to prevent
  leaking "dangling threads" even if the thread was not started
  yet.

(cherry picked from commit 6351842121)
2023-10-02 17:47:10 +02:00
Miss Islington (bot)
41eb0c7286
[3.12] gh-109592: test_eintr tolerates 20 ms when comparing timings (GH-110102) (#110106)
gh-109592: test_eintr tolerates 20 ms when comparing timings (GH-110102)
(cherry picked from commit 9c73a9acec)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-02 17:46:45 +02:00
Victor Stinner
d0641ab676
[3.12] gh-110052: Fix faulthandler for freed tstate (#110069) (#110071)
gh-110052: Fix faulthandler for freed tstate (#110069)

faulthandler now detected freed interp and freed tstate, and no
longer dereference them.

(cherry picked from commit 2e37a38bcb)
2023-10-02 17:44:51 +02:00
Miss Islington (bot)
a2074911ba
[3.12] gh-110036: multiprocessing Popen.terminate() catches PermissionError (GH-110037) (#110064)
gh-110036: multiprocessing Popen.terminate() catches PermissionError (GH-110037)

On Windows, multiprocessing Popen.terminate() now catchs
PermissionError and get the process exit code. If the process is
still running, raise again the PermissionError. Otherwise, the
process terminated as expected: store its exit code.
(cherry picked from commit bd4518c60c)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-02 17:44:26 +02:00
Miss Islington (bot)
aaa8bf18c6
[3.12] gh-109960: Remove test_pty timeout of 10 seconds (GH-110058) (#110060)
gh-109960: Remove test_pty timeout of 10 seconds (GH-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.
(cherry picked from commit 5fdcea7440)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-02 17:43:38 +02:00
Miss Islington (bot)
2b96102f29
[3.12] gh-109889: fix compiler's redundant NOP detection to look past NOPs with no lineno when looking for the next instruction's lineno (GH-109987) (#110048)
gh-109889: fix compiler's redundant NOP detection to look past NOPs with no lineno when looking for the next instruction's lineno (GH-109987)
(cherry picked from commit f580edcc6a)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2023-10-02 17:43:16 +02:00
Davide Rizzo
c794103417
[3.12] gh-110038: KqueueSelector must count all read/write events (GH-110039) (#110043)
[3.12] gh-110038: KqueueSelector must count all read/write events (GH-110039).
(cherry picked from commit b14f0ab51c)
2023-10-02 17:42:55 +02:00
Miss Islington (bot)
4bdcb99469
[3.12] gh-110033: Fix signal test_interprocess_signal() (GH-110035) (#110040)
gh-110033: Fix signal test_interprocess_signal() (GH-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.
(cherry picked from commit 7e0fbf5175)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-02 17:42:40 +02:00
Miss Islington (bot)
9cf6d89165
[3.12] gh-109594: Fix concurrent.futures test_timeout() (GH-110018) (#110021)
gh-109594: Fix concurrent.futures test_timeout() (GH-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.
(cherry picked from commit 9be283e5e1)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-02 17:42:03 +02:00
Jelle Zijlstra
9be6a11199
[3.12] gh-109818: reprlib.recursive_repr copies __type_params__ (… (#109999)
[3.12] gh-109818: `reprlib.recursive_repr` copies `__type_params__` (GH-109819).
(cherry picked from commit f65f9e80fe)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-10-02 17:41:26 +02:00
Miss Islington (bot)
dd67e59bb1
[3.12] gh-109955 : Update state transition comments for asyncio.Task (GH-109910) (#109992)
gh-109955 : Update state transition comments for asyncio.Task (GH-109910)
(cherry picked from commit 45cf5b0c69)

Co-authored-by: Kristján Valur Jónsson <sweskman@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-10-02 17:41:12 +02:00
Miss Islington (bot)
73ec1e7c21
[3.12] gh-109565: Fix concurrent.futures test_future_times_out() (GH-109949) (#109952)
gh-109565: Fix concurrent.futures test_future_times_out() (GH-109949)

as_completed() uses a timeout of 100 ms instead of 10 ms. Windows
monotonic clock resolution is around 15.6 ms.
(cherry picked from commit b1aebf1e65)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-02 17:40:16 +02:00
Victor Stinner
1fc25a389c
[3.12] gh-109615: Fix test_tools.test_freeze SRCDIR (#109935) (#109950)
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.

(cherry picked from commit 1512d6c6ee)
2023-10-02 17:40:02 +02:00
Miss Islington (bot)
3ab9fdaedb
[3.12] Remove loop from docstring for asyncio.streams.open_connection (GH-108528) (#109941)
Remove loop from docstring for asyncio.streams.open_connection (GH-108528)
(cherry picked from commit e721f7a951)

Co-authored-by: Tom Gillespie <tgbugs@gmail.com>
2023-10-02 17:39:34 +02:00
Miss Islington (bot)
95fd4edc63
[3.12] gh-109098: Fuzz re module instead of internal sre (GH-109911) (#109932)
gh-109098: Fuzz re module instead of internal sre (GH-109911)

* gh-109098: Fuzz re module instead of internal sre
* Fix c-analyzer globals test failure
* Put globals exception in ignored.tsv
(cherry picked from commit a829356f86)

Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
2023-10-02 17:39:07 +02:00
Miss Islington (bot)
1f622004c5
[3.12] gh-109845: Make test_ftplib more stable under load (GH-109912) (#109919)
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.
(cherry picked from commit 2ef2fffe3b)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-02 17:38:07 +02:00
Miss Islington (bot)
b0e377f694
[3.12] More informative docstrings in the random module (gh-109745) (#109905)
More informative docstrings in the random module (gh-109745)
(cherry picked from commit 19bf398695)

Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
2023-10-02 17:37:56 +02:00
Miss Islington (bot)
b723b8a13d
[3.12] gh-109593: Fix reentrancy issue in multiprocessing resource_tracker (GH-109629) (#109898)
gh-109593: Fix reentrancy issue in multiprocessing resource_tracker (GH-109629)

---------

(cherry picked from commit 0eb98837b6)

Co-authored-by: Antoine Pitrou <antoine@python.org>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-10-02 17:37:40 +02:00
Miss Islington (bot)
84f9da9ab5
[3.12] gh-109832: concurrent.futures test_deadlock restores sys.stderr (GH-109887) (#109892)
gh-109832: concurrent.futures test_deadlock restores sys.stderr (GH-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().
(cherry picked from commit 2897142d2e)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-02 17:37:25 +02:00
Miss Islington (bot)
65c845e065
[3.12] gh-109631: Allow interruption of short repeated regex matches (GH-109867) (#109886)
gh-109631: Allow interruption of short repeated regex matches (GH-109867)

Counting for signal checking now continues in new match from the point where
it ended in the previous match instead of starting from 0.
(cherry picked from commit 8ac2085b80)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-02 17:36:29 +02:00
Miss Islington (bot)
d09a3145b5
[3.12] gh-89363: Skip threading test_is_alive_after_fork() if ASAN (GH-109835) (#109855)
gh-89363: Skip threading test_is_alive_after_fork() if ASAN (GH-109835)

Skip test_is_alive_after_fork() of test_threading if Python is built
with Address Sanitizer (ASAN).
(cherry picked from commit bc06743533)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-02 17:36:04 +02:00
Miss Islington (bot)
e25bc38ebb
[3.12] gh-109702: Increase concurrent_futures deadlock timeout (GH-109703) (#109705)
gh-109702: Increase concurrent_futures deadlock timeout (GH-109703)

Replace SHORT_TIMEOUT with LONG_TIMEOUT in test_deadlock of
test_concurrent_futures.
(cherry picked from commit 1eb1b45183)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-02 17:35:36 +02:00
Miss Islington (bot)
8c5fd2105c
[3.12] gh-109625: Move _ready_to_import() from test_import to support.import_helper (GH-109626) (#109640)
gh-109625: Move _ready_to_import() from test_import to support.import_helper (GH-109626)
(cherry picked from commit 115c49ad5a)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-10-02 17:35:03 +02:00