]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
2 years agoDocs: Superseded modules: list only module names (#109439)
Hugo van Kemenade [Fri, 15 Sep 2023 12:56:23 +0000 (06:56 -0600)] 
Docs: Superseded modules: list only module names (#109439)

2 years agogh-109395: Remove skipped macOS builds from Azure Pipelines (#109400)
Nikita Sobolev [Fri, 15 Sep 2023 08:55:09 +0000 (11:55 +0300)] 
gh-109395: Remove skipped macOS builds from Azure Pipelines (#109400)

2 years agogh-108303: Move `test_future` into its own test_future_stmt subdir (#109368)
Nikita Sobolev [Fri, 15 Sep 2023 07:52:24 +0000 (10:52 +0300)] 
gh-108303: Move `test_future` into its own test_future_stmt subdir (#109368)

2 years agogh-109395: Remove skipped coverage job from Azure Pipelines (#109412)
Hugo van Kemenade [Fri, 15 Sep 2023 05:27:47 +0000 (23:27 -0600)] 
gh-109395: Remove skipped coverage job from Azure Pipelines (#109412)

2 years agogh-109425: regrtest decodes worker stdout with backslashreplace (#109428)
Victor Stinner [Thu, 14 Sep 2023 23:37:37 +0000 (01:37 +0200)] 
gh-109425: regrtest decodes worker stdout with backslashreplace (#109428)

libregrtest now decodes stdout of test worker processes with the
"backslashreplace" error handler to log corrupted stdout, instead of
failing with an error and not logging the stdout.

2 years agogh-109375: Fix bug where pdb registers an alias without an associated command (#109376)
buermarc [Thu, 14 Sep 2023 21:31:30 +0000 (23:31 +0200)] 
gh-109375: Fix bug where pdb registers an alias without an associated command (#109376)

2 years agogh-109396: Fix test_socket.test_hmac_sha1() in FIPS mode (#109423)
Victor Stinner [Thu, 14 Sep 2023 21:24:11 +0000 (23:24 +0200)] 
gh-109396: Fix test_socket.test_hmac_sha1() in FIPS mode (#109423)

Use a longer key: FIPS mode requires at least of at least 112 bits.
The previous key was only 32 bits.

2 years agogh-109418: Fix hypothesis strategy for b2a_roundtrip test (#109419)
Nikita Sobolev [Thu, 14 Sep 2023 20:38:31 +0000 (23:38 +0300)] 
gh-109418: Fix hypothesis strategy for b2a_roundtrip test (#109419)

2 years agogh-109413: libregrtest: Add and improve type annotations (#109405)
Alex Waygood [Thu, 14 Sep 2023 18:33:18 +0000 (19:33 +0100)] 
gh-109413: libregrtest: Add and improve type annotations (#109405)

2 years agogh-101100: Fix sphinx warnings in `turtle.rst` (#109394)
Nikita Sobolev [Thu, 14 Sep 2023 18:24:18 +0000 (21:24 +0300)] 
gh-101100: Fix sphinx warnings in `turtle.rst` (#109394)

2 years agogh-109219: propagate free vars through type param scopes (#109377)
Carl Meyer [Thu, 14 Sep 2023 16:20:32 +0000 (10:20 -0600)] 
gh-109219: propagate free vars through type param scopes (#109377)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2 years agogh-105658: fix excess trace events for except block ending with a conditional block...
Irit Katriel [Thu, 14 Sep 2023 16:06:08 +0000 (17:06 +0100)] 
gh-105658: fix excess trace events for except block ending with a conditional block (#109384)

2 years agodump readable opcode names in flowgraph debug utility (#109392)
Carl Meyer [Thu, 14 Sep 2023 14:28:21 +0000 (08:28 -0600)] 
dump readable opcode names in flowgraph debug utility (#109392)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2 years agogh-109402: Fix regrtest findtests() (#109403)
Victor Stinner [Thu, 14 Sep 2023 13:15:42 +0000 (15:15 +0200)] 
gh-109402: Fix regrtest findtests() (#109403)

Check for the full module name in SPLITTESTDIRS, not the relative
module name.

2 years agogh-107298: Document PyMODINIT_FUNC macro (#109236)
Victor Stinner [Thu, 14 Sep 2023 12:56:43 +0000 (14:56 +0200)] 
gh-107298: Document PyMODINIT_FUNC macro (#109236)

Document PyMODINIT_FUNC macro.

Remove links to PyAPI_FUNC() and PyAPI_DATA() macros since they are
not documented. These macros should only be used to define the Python
C API. They should not be used outside Python code base.

2 years agogh-107782: Use _testcapi to test non-representable signatures (GH-109325)
Serhiy Storchaka [Thu, 14 Sep 2023 06:12:17 +0000 (09:12 +0300)] 
gh-107782: Use _testcapi to test non-representable signatures (GH-109325)

Builtin functions and methods that have non-representable signatures today
will have representable signatures yesterday, and they will become unusable
for testing this feature.

So we need to add special functions and methods to the _testcapi module
that always have non-representable signatures.

2 years agoAdd missing PyDoc_STR to GenericAlias.__parameters__ (#108811)
James Hilton-Balfe [Thu, 14 Sep 2023 03:42:44 +0000 (04:42 +0100)] 
Add missing PyDoc_STR to GenericAlias.__parameters__ (#108811)

2 years agoFix invocation of wasm_build.py for node (GH-109383)
Sam Gross [Wed, 13 Sep 2023 22:28:08 +0000 (18:28 -0400)] 
Fix invocation of wasm_build.py for node (GH-109383)

2 years agoGH-104584: Don't call executors from JUMP_BACKWARD (GH-109347)
Brandt Bucher [Wed, 13 Sep 2023 17:26:50 +0000 (10:26 -0700)] 
GH-104584: Don't call executors from JUMP_BACKWARD (GH-109347)

2 years agoGH-105848: Replace KW_NAMES + CALL with LOAD_CONST + CALL_KW (GH-109300)
Brandt Bucher [Wed, 13 Sep 2023 17:25:45 +0000 (10:25 -0700)] 
GH-105848: Replace KW_NAMES + CALL with LOAD_CONST + CALL_KW (GH-109300)

2 years agogh-109341: Fix crash on compiling invalid AST including TypeAlias (#109349)
Jelle Zijlstra [Wed, 13 Sep 2023 16:00:39 +0000 (09:00 -0700)] 
gh-109341: Fix crash on compiling invalid AST including TypeAlias (#109349)

2 years agogh-109351: Fix crash when compiling AST with invalid NamedExpr (#109352)
Jelle Zijlstra [Wed, 13 Sep 2023 16:00:15 +0000 (09:00 -0700)] 
gh-109351: Fix crash when compiling AST with invalid NamedExpr (#109352)

2 years agogh-109156: Add tests for de-instrumenting instructions with instrumented lines (GH...
Tian Gao [Wed, 13 Sep 2023 08:47:35 +0000 (01:47 -0700)] 
gh-109156: Add tests for de-instrumenting instructions with instrumented lines (GH-109157)

2 years agoFix variable name in dis documentation example (GH-109343)
Oleksandr Kravets [Wed, 13 Sep 2023 05:07:56 +0000 (01:07 -0400)] 
Fix variable name in dis documentation example (GH-109343)

BINARY_SUBSCR example erroneously uses two different names `key` and `index` to refer to the same variable. STORE_SUBSCR and DELETE_SUBSCR use only `key` in the same context. Changing `index` to `key` for consistency.

2 years agogh-105189: fix importlib.resources.abc deprecation docs (#105232)
Thomas Grainger [Wed, 13 Sep 2023 04:42:26 +0000 (21:42 -0700)] 
gh-105189: fix importlib.resources.abc deprecation docs (#105232)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2 years agogh-104736: Fix test_gdb tests on ppc64le with clang (#109360)
Victor Stinner [Wed, 13 Sep 2023 04:24:32 +0000 (06:24 +0200)] 
gh-104736: Fix test_gdb tests on ppc64le with clang (#109360)

Fix test_gdb on Python built with LLVM clang 16 on Linux ppc64le (ex:
Fedora 38). Search patterns in gdb "bt" command output to detect
when gdb fails to retrieve the traceback. For example, skip a test if
"Backtrace stopped: frame did not save the PC" is found.

2 years agogh-108346: Fix failed benchmark in decimal (#108353)
Charlie Zhao [Wed, 13 Sep 2023 04:17:55 +0000 (12:17 +0800)] 
gh-108346: Fix failed benchmark in decimal (#108353)

Fix benchmark in decimal to work again after the int str conversion limits.

2 years agogh-109357: Fix test_monitoring.test_gh108976() (#109358)
Victor Stinner [Wed, 13 Sep 2023 01:54:28 +0000 (03:54 +0200)] 
gh-109357: Fix test_monitoring.test_gh108976() (#109358)

The test now calls free_tool_id() so it can be run multiple times in
the same process. For example, the following command no longer fails:

    python -m test test_monitoring -R 3:3

2 years agogh-109276: libregrtest: fix work dir on WASI (#109356)
Victor Stinner [Wed, 13 Sep 2023 01:40:44 +0000 (03:40 +0200)] 
gh-109276: libregrtest: fix work dir on WASI (#109356)

On WASI platform, get_temp_dir() should behave differently since the
parent process is a WASI process and uses a different get_temp_dir()
path.

Fix also WorkerThread._runtest(): don't read JSON file if the worker
process exit code is non-zero.

2 years agogh-109276: libregrtest: WASM use stdout for JSON (#109355)
Victor Stinner [Wed, 13 Sep 2023 00:24:43 +0000 (02:24 +0200)] 
gh-109276: libregrtest: WASM use stdout for JSON (#109355)

On Emscripten and WASI, or if --python command line is used,
libregrtest now writes JSON into stdout, instead of using a name
file.

* Add JsonFileType.STDOUT.
* Remove JsonFileType.FILENAME.
* test.pythoninfo logs environment variables related to
  cross-compilation and running Python on Emscripten/WASI.

2 years agogh-109276: libregrtest: WASM use filename for JSON (#109340)
Victor Stinner [Tue, 12 Sep 2023 22:41:25 +0000 (00:41 +0200)] 
gh-109276: libregrtest: WASM use filename for JSON (#109340)

On Emscripten and WASI platforms, or if --python command line option
is used, libregrtest now uses a filename for the JSON file.

Emscripten and WASI buildbot workers run the main test process with a
different Python (Linux) which spawns Emscripten/WASI processes using
the command specified in --python command line option. Passing a file
descriptor from the parent process to the child process doesn't work
in this case.

* Add JsonFile and JsonFileType classes
* Add RunTests.json_file_use_filename() method.
* Add a test in test_regrtest on the --python command line option.
* test_regrtest: add parallel=False parameter.
* Split long RunWorkers._runtest() function into sub-functions.

2 years agoGH-109330: Dump and compare stats using opcode names, not numbers (GH-109335)
Michael Droettboom [Tue, 12 Sep 2023 21:12:57 +0000 (17:12 -0400)] 
GH-109330: Dump and compare stats using opcode names, not numbers (GH-109335)

2 years agoGH-104395: Add a link in 'Meta Information' to the docs download page (#104443)
Adam Turner [Tue, 12 Sep 2023 20:32:13 +0000 (21:32 +0100)] 
GH-104395: Add a link in 'Meta Information' to the docs download page (#104443)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2 years agoUpdate workflow permissions in require-pr-label Action (#109342)
Mariatta [Tue, 12 Sep 2023 19:03:55 +0000 (12:03 -0700)] 
Update workflow permissions in require-pr-label Action (#109342)

Change the permission from `read` to `write`.

2 years agogh-106581: Honor 'always_exits' in write_components() (#109338)
Guido van Rossum [Tue, 12 Sep 2023 17:58:40 +0000 (10:58 -0700)] 
gh-106581: Honor 'always_exits' in write_components() (#109338)

I must have overlooked this when refactoring the code generator.
The Tier 1 interpreter contained a few silly things like
```
            goto resume_frame;
            STACK_SHRINK(1);
```
(and other variations, some where the unconditional `goto` was hidden in a macro).

2 years agogh-109276: test.pythoninfo gets more test.support data (#109337)
Victor Stinner [Tue, 12 Sep 2023 16:43:32 +0000 (18:43 +0200)] 
gh-109276: test.pythoninfo gets more test.support data (#109337)

Collect data from:

* test.support
* test.support.os_helper
* test.support.socket_helper
* test.support.threading_helper

2 years agogh-109319: deprecate dis.HAVE_ARGUMENT (#109320)
Irit Katriel [Tue, 12 Sep 2023 15:45:35 +0000 (16:45 +0100)] 
gh-109319: deprecate dis.HAVE_ARGUMENT (#109320)

2 years agogh-60283: Check for redefined test names in CI (#109161)
Hugo van Kemenade [Tue, 12 Sep 2023 15:28:20 +0000 (09:28 -0600)] 
gh-60283: Check for redefined test names in CI (#109161)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2 years agogh-109184: update traceback module doc w.r.t notes (message is no longer always at...
Irit Katriel [Tue, 12 Sep 2023 14:54:04 +0000 (15:54 +0100)] 
gh-109184: update traceback module doc w.r.t notes (message is no longer always at the end) (#109201)

2 years agogh-109266: Fix msvcrt.kbhit's documented return value (GH-109267)
AN Long [Tue, 12 Sep 2023 14:44:48 +0000 (22:44 +0800)] 
gh-109266: Fix msvcrt.kbhit's documented return value (GH-109267)

2 years agogh-108303: Add `Lib/test/tokenizedata` to `TESTSUBDIRS` (#109314)
Nikita Sobolev [Tue, 12 Sep 2023 14:05:29 +0000 (17:05 +0300)] 
gh-108303: Add `Lib/test/tokenizedata` to `TESTSUBDIRS` (#109314)

2 years agogh-84867: Do not load tests from TestCase and FunctionTestCase (GH-100497)
Nikita Sobolev [Tue, 12 Sep 2023 13:33:30 +0000 (16:33 +0300)] 
gh-84867: Do not load tests from TestCase and FunctionTestCase (GH-100497)

2 years agogh-109276: libregrtest: fix worker working dir (#109313)
Victor Stinner [Tue, 12 Sep 2023 13:13:29 +0000 (15:13 +0200)] 
gh-109276: libregrtest: fix worker working dir (#109313)

Fix Emscripten and WASI: start the test worker process in the Python
source code directory, where 'python.js' and 'python.wasm' can be
found. Then worker_process() changes to a temporary directory created
to run tests.

* create_worker_process() uses os_helper.SAVEDCWD as cwd.
* worker_process() uses get_temp_dir() as the parent directory for
  get_work_dir().
* Don't use plural but singual for "test" in "Run 1 test ..."
  message.
* Remove unused imports.
* Add WORK_DIR_PREFIX and WORKER_WORK_DIR_PREFIX constants.

2 years agogh-109256: allocate opcode IDs for internal opcodes in their own range (#109269)
Irit Katriel [Tue, 12 Sep 2023 10:36:17 +0000 (11:36 +0100)] 
gh-109256: allocate opcode IDs for internal opcodes in their own range (#109269)

2 years agogh-109216: Fix possible memory leak in `BUILD_MAP` (#109257)
Nikita Sobolev [Tue, 12 Sep 2023 09:37:22 +0000 (12:37 +0300)] 
gh-109216: Fix possible memory leak in `BUILD_MAP` (#109257)

2 years agogh-108303: Move tokenize-related data to Lib/test/tokenizedata (GH-109265)
Nikita Sobolev [Tue, 12 Sep 2023 06:37:42 +0000 (09:37 +0300)] 
gh-108303: Move tokenize-related data to Lib/test/tokenizedata (GH-109265)

2 years agogh-109276: libregrtest: limit number workers (#109288)
Victor Stinner [Tue, 12 Sep 2023 03:47:04 +0000 (05:47 +0200)] 
gh-109276: libregrtest: limit number workers (#109288)

Don't spawn more threads than the number of jobs: these worker
threads would never get anything to do.

* Add the number of tests in "Run ... tests in ..." message.
* Add RunTests.get_jobs() method.
* Add plural() function.
* count() uses f-string.

2 years agogh-109276: libregrtest calls random.seed() before each test (#109279)
Victor Stinner [Tue, 12 Sep 2023 03:35:08 +0000 (05:35 +0200)] 
gh-109276: libregrtest calls random.seed() before each test (#109279)

libregrtest now calls random.seed() before running each test file
when -r/--randomize command line option is used. Moreover, it's also
called in worker processes. It should help to make tests more
deterministic. Previously, it was only called once in the main
process before running all test files and it was not called in worker
processes.

* Convert some f-strings to regular strings in test_regrtest when
  f-string is not needed.
* Remove unused all_methods variable from test_regrtest.
* Add RunTests members are now mandatory.

2 years agogh-109276: libregrtest only checks saved_test_environment() once (#109278)
Victor Stinner [Tue, 12 Sep 2023 03:01:33 +0000 (05:01 +0200)] 
gh-109276: libregrtest only checks saved_test_environment() once (#109278)

There is no need to check for environment changes twice.

2 years agogh-109276: Complete test.pythoninfo (#109312)
Victor Stinner [Tue, 12 Sep 2023 02:50:05 +0000 (04:50 +0200)] 
gh-109276: Complete test.pythoninfo (#109312)

* Enable collect_sysconfig() on Windows.
* Add sysconfig 'abs_builddir' and 'srcdir'
* Add sysconfig.is_python_build()
* Add tempfile.gettempdir()
* Remove compatiblity with Python 2.7 (print_function).

2 years agogh-109295: Skip test_generated_cases if different mount drives (#109308)
Victor Stinner [Tue, 12 Sep 2023 02:30:07 +0000 (04:30 +0200)] 
gh-109295: Skip test_generated_cases if different mount drives (#109308)

On Windows, skip the test if the current working directory and the
Python source code directory have different mount drives. It happens
if the temporary directory is on a different mount drive than the
Python source code.

2 years agoFix iter_index() to work with lists which do not support stop=None. (gh-109306)
Raymond Hettinger [Tue, 12 Sep 2023 02:04:28 +0000 (04:04 +0200)] 
Fix iter_index() to work with lists which do not support stop=None. (gh-109306)

2 years agogh-109295: Fix test_os.test_access_denied() for TEMP=cwd (#109299)
Victor Stinner [Tue, 12 Sep 2023 01:35:26 +0000 (03:35 +0200)] 
gh-109295: Fix test_os.test_access_denied() for TEMP=cwd (#109299)

Fix test_os.test_access_denied() when the TEMP environment variable
is equal to the current working directory. Run the test using a
different filename, since self.fname already exists in this case.

2 years agogh-109295: Clean up multiprocessing in test_asyncio and test_compileall (#109298)
Victor Stinner [Tue, 12 Sep 2023 01:31:15 +0000 (03:31 +0200)] 
gh-109295: Clean up multiprocessing in test_asyncio and test_compileall (#109298)

test_asyncio and test_compileall now clean up multiprocessing by
calling multiprocessing _cleanup_tests(): explicitly clean up
resources and stop background processes like the resource tracker.

2 years agoGH-106734: Disable tab completion in pdb's multiline mode (GH-106735)
Tian Gao [Tue, 12 Sep 2023 01:28:43 +0000 (18:28 -0700)] 
GH-106734: Disable tab completion in pdb's multiline mode (GH-106735)

2 years agogh-109118: Disallow nested scopes within PEP 695 scopes within classes (#109196)
Jelle Zijlstra [Tue, 12 Sep 2023 00:11:06 +0000 (17:11 -0700)] 
gh-109118: Disallow nested scopes within PEP 695 scopes within classes (#109196)

Fixes #109118. Fixes #109194.

Co-authored-by: Carl Meyer <carl@oddbird.net>
2 years agogh-109292: add symtable impact of PEP 709 to What's New (#109293)
Carl Meyer [Tue, 12 Sep 2023 00:03:04 +0000 (18:03 -0600)] 
gh-109292: add symtable impact of PEP 709 to What's New (#109293)

2 years agogh-109195: fix source location for super load before LOAD_SUPER_ATTR (#109289)
Carl Meyer [Mon, 11 Sep 2023 23:35:49 +0000 (17:35 -0600)] 
gh-109195: fix source location for super load before LOAD_SUPER_ATTR (#109289)

2 years agogh-109214: Rename SAVE_IP to _SET_IP, and similar (#109285)
Guido van Rossum [Mon, 11 Sep 2023 22:39:19 +0000 (15:39 -0700)] 
gh-109214: Rename SAVE_IP to _SET_IP, and similar (#109285)

* Rename SAVE_IP to _SET_IP
* Rename EXIT_TRACE to _EXIT_TRACE
* Rename SAVE_CURRENT_IP to _SAVE_CURRENT_IP
* Rename INSERT to _INSERT (This is for Ken Jin's abstract interpreter)
* Rename IS_NONE to _IS_NONE
* Rename JUMP_TO_TOP to _JUMP_TO_TOP

2 years agogh-107322: zipapp: Remove the suggestion to remove .dist-info directories (#107296)
wim glenn [Mon, 11 Sep 2023 19:44:13 +0000 (14:44 -0500)] 
gh-107322: zipapp: Remove the suggestion to remove .dist-info directories (#107296)

Removed zipapp suggestion to rm .dist-info subdirectories. This totally breaks importlib.metadata

2 years agogh-109039: Branch prediction for Tier 2 interpreter (#109038)
Guido van Rossum [Mon, 11 Sep 2023 18:20:24 +0000 (11:20 -0700)] 
gh-109039: Branch prediction for Tier 2 interpreter (#109038)

This adds a 16-bit inline cache entry to the conditional branch instructions POP_JUMP_IF_{FALSE,TRUE,NONE,NOT_NONE} and their instrumented variants, which is used to keep track of the branch direction.

Each time we encounter these instructions we shift the cache entry left by one and set the bottom bit to whether we jumped.

Then when it's time to translate such a branch to Tier 2 uops, we use the bit count from the cache entry to decided whether to continue translating the "didn't jump" branch or the "jumped" branch.

The counter is initialized to a pattern of alternating ones and zeros to avoid bias.

The .pyc file magic number is updated. There's a new test, some fixes for existing tests, and a few miscellaneous cleanups.

2 years agogh-109179: Fix traceback display for SyntaxErrors with notes (#109197)
Irit Katriel [Mon, 11 Sep 2023 18:18:34 +0000 (19:18 +0100)] 
gh-109179: Fix traceback display for SyntaxErrors with notes (#109197)

2 years agogh-109276: libregrtest: use separated file for JSON (#109277)
Victor Stinner [Mon, 11 Sep 2023 17:33:42 +0000 (19:33 +0200)] 
gh-109276: libregrtest: use separated file for JSON (#109277)

libregrtest now uses a separated file descriptor to write test result
as JSON.  Previously, if a test wrote debug messages late around the
JSON, the main test process failed to parse JSON.

Rename TestResult.write_json() to TestResult.write_json_into().

worker_process() no longer writes an empty line at the end. There is
no need to separate test process output from the JSON output anymore,
since JSON is now written into a separated file descriptor.

create_worker_process() now always spawn the process with
close_fds=True.

2 years agogh-90805: Make sure test_functools works with and without _functoolsmodule (GH-108644)
Nikita Sobolev [Mon, 11 Sep 2023 16:13:37 +0000 (19:13 +0300)] 
gh-90805: Make sure test_functools works with and without _functoolsmodule (GH-108644)

2 years agogh-109190: What's New in 3.12: Add subheadings to removals for easy linking (#109159)
Hugo van Kemenade [Mon, 11 Sep 2023 16:06:16 +0000 (10:06 -0600)] 
gh-109190: What's New in 3.12: Add subheadings to removals for easy linking (#109159)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2 years agogh-108987: Fix _thread.start_new_thread() race condition (#109135)
Victor Stinner [Mon, 11 Sep 2023 15:27:03 +0000 (17:27 +0200)] 
gh-108987: Fix _thread.start_new_thread() race condition (#109135)

Fix _thread.start_new_thread() race condition. If a thread is created
during Python finalization, the newly spawned thread now exits
immediately instead of trying to access freed memory and lead to a
crash.

thread_run() calls PyEval_AcquireThread() which checks if the thread
must exit. The problem was that tstate was dereferenced earlier in
_PyThreadState_Bind() which leads to a crash most of the time.

Move _PyThreadState_CheckConsistency() from thread_run() to
_PyThreadState_Bind().

2 years agogh-109182: Fix and improve tests for gh-108654 (GH-109189)
Serhiy Storchaka [Mon, 11 Sep 2023 14:50:33 +0000 (17:50 +0300)] 
gh-109182: Fix and improve tests for gh-108654 (GH-109189)

2 years agoGH-108976. Keep monitoring data structures valid during de-optimization during callba...
Mark Shannon [Mon, 11 Sep 2023 13:37:09 +0000 (14:37 +0100)] 
GH-108976. Keep monitoring data structures valid during de-optimization during callback. (GH-109131)

2 years agoBetter integration of doctest and unittest in test_ctypes.test_objects (GH-108922)
Serhiy Storchaka [Mon, 11 Sep 2023 11:05:30 +0000 (14:05 +0300)] 
Better integration of doctest and unittest in test_ctypes.test_objects (GH-108922)

Better integration of docrtest and unittest in test_ctypes.test_objects

2 years agoTest DocTestFinder directly instead of calling support.run_doctest() (GH-108917)
Serhiy Storchaka [Mon, 11 Sep 2023 11:03:30 +0000 (14:03 +0300)] 
Test DocTestFinder directly instead of calling support.run_doctest() (GH-108917)

2 years agogh-109162: libregrtest: move code around (#109253)
Victor Stinner [Mon, 11 Sep 2023 08:52:03 +0000 (10:52 +0200)] 
gh-109162: libregrtest: move code around (#109253)

* Move Regrtest.display_header() to utils.py.
* Move cleanup_temp_dir() to utils.py.
* Move list_cases() to findtests.py.

2 years agogh-107219: Fix concurrent.futures terminate_broken() (#109244)
Victor Stinner [Mon, 11 Sep 2023 08:11:31 +0000 (10:11 +0200)] 
gh-107219: Fix concurrent.futures terminate_broken() (#109244)

Fix a race condition in concurrent.futures. When a process in the
process pool was terminated abruptly (while the future was running or
pending), close the connection write end. If the call queue is
blocked on sending bytes to a worker process, closing the connection
write end interrupts the send, so the queue can be closed.

Changes:

* _ExecutorManagerThread.terminate_broken() now closes
  call_queue._writer.
* multiprocessing PipeConnection.close() now interrupts
  WaitForMultipleObjects() in _send_bytes() by cancelling the
  overlapped operation.

2 years agoGH-108614: Increase importlib MAGIC for RESUME_CHECK instruction (#109247)
Victor Stinner [Mon, 11 Sep 2023 07:34:04 +0000 (09:34 +0200)] 
GH-108614: Increase importlib MAGIC for RESUME_CHECK instruction (#109247)

2 years agogh-109162: libregrtest: use relative imports (#109250)
Victor Stinner [Mon, 11 Sep 2023 07:02:35 +0000 (09:02 +0200)] 
gh-109162: libregrtest: use relative imports (#109250)

libregrtest.__init__ no longer exposes any symbol, so
"python -m test.libregrtest.worker" imports less modules.

2 years agogh-109162: libregrtest: rename runtest_mp.py to run_workers.py (#109248)
Victor Stinner [Mon, 11 Sep 2023 03:27:37 +0000 (05:27 +0200)] 
gh-109162: libregrtest: rename runtest_mp.py to run_workers.py (#109248)

* Rename runtest_mp.py to run_workers.py
* Move exit_timeout() and temp_cwd() context managers from
  Regrtest.main() to Regrtest.run_tests(). Actions like --list-tests
  or --list-cases don't need these protections.
* Regrtest: remove selected and tests attributes. Pass 'selected' to
  list_tests(), list_cases() and run_tests(). display_result() now
  expects a TestTuple, instead of TestList.
* Rename setup_tests() to setup_process() and rename setup_support()
  to setup_tests().
* Move _adjust_resource_limits() to utils and rename it to
  adjust_rlimit_nofile().
* Move replace_stdout() to utils.
* Fix RunTests.verbose type: it's an int.

2 years agogh-109162: libregrtest: fix Logger (#109246)
Victor Stinner [Mon, 11 Sep 2023 01:46:26 +0000 (03:46 +0200)] 
gh-109162: libregrtest: fix Logger (#109246)

* Pass results, quiet and pgo to Logger constructor.
* Move display_progress() method from Regrtest to Logger.
* No longer pass Regrtest to RunWorkers, but logger and results.

2 years agogh-109162: libregrtest: add single.py and result.py (#109243)
Victor Stinner [Mon, 11 Sep 2023 00:07:18 +0000 (02:07 +0200)] 
gh-109162: libregrtest: add single.py and result.py (#109243)

* Add single.py and result.py files.
* Rename runtest.py to runtests.py.
* Move run_single_test() function and its helper functions to
  single.py.
* Move remove_testfn(), abs_module_name() and normalize_test_name()
  to utils.py.
* Move setup_support() to setup.py.
* Move type hints like TestName to utils.py.
* Rename runtest.py to runtests.py.

2 years agogh-109162: libregrtest: add worker.py (#109229)
Victor Stinner [Sun, 10 Sep 2023 23:11:22 +0000 (01:11 +0200)] 
gh-109162: libregrtest: add worker.py (#109229)

Add new worker.py file:

* Move create_worker_process() and worker_process() to this file.
* Add main() function to worker.py. create_worker_process() now
  runs the command: "python -m test.libregrtest.worker JSON".
* create_worker_process() now starts the worker process in the
  current working directory. Regrtest now gets the absolute path of
  the reflog.txt filename: -R command line option filename.
* Remove --worker-json command line option.
  Remove test_regrtest.test_worker_json().

Related changes:

* Add write_json() and from_json() methods to TestResult.
* Rename select_temp_dir() to get_temp_dir() and move it to utils.
* Rename make_temp_dir() to get_work_dir() and move it to utils.
  It no longer calls os.makedirs(): Regrtest.main() now calls it.
* Move fix_umask() to utils. The function is now called by
  setup_tests().
* Move StrPath to utils.
* Add exit_timeout() context manager to utils.
* RunTests: Replace junit_filename (StrPath) with use_junit (bool).

2 years agogh-109230: test_pyexpat no longer depends on the current directory (#109233)
Victor Stinner [Sun, 10 Sep 2023 22:16:59 +0000 (00:16 +0200)] 
gh-109230: test_pyexpat no longer depends on the current directory (#109233)

Fix test_pyexpat.test_exception(): it can now be run from a directory
different than Python source code directory. Before, the test failed
in this case.

Skip the test if Modules/pyexpat.c source is not available. Skip also
the test on Python implementations other than CPython.

2 years agogh-109237: Fix test_site for non-ASCII working directory (#109238)
Victor Stinner [Sun, 10 Sep 2023 22:04:35 +0000 (00:04 +0200)] 
gh-109237: Fix test_site for non-ASCII working directory (#109238)

Fix test_site.test_underpth_basic() when the working directory
contains at least one non-ASCII character: encode the "._pth" file to
UTF-8 and enable the UTF-8 Mode to use UTF-8 for the child process
stdout.

2 years agogh-50644: Forbid pickling of codecs streams (GH-109180)
Serhiy Storchaka [Sun, 10 Sep 2023 17:06:09 +0000 (20:06 +0300)] 
gh-50644: Forbid pickling of codecs streams (GH-109180)

Attempts to pickle or create a shallow or deep copy of codecs streams
now raise a TypeError.

Previously, copying failed with a RecursionError, while pickling
produced wrong results that eventually caused unpickling to fail with
a RecursionError.

2 years agogh-109054: Don't use libatomic on cross-compilation (#109211)
Victor Stinner [Sun, 10 Sep 2023 16:21:13 +0000 (18:21 +0200)] 
gh-109054: Don't use libatomic on cross-compilation (#109211)

configure no longer uses libatomic by default when Python is
cross-compiled. The LIBATOMIC variable can be set manually in this
case:

    ./configure LIBATOMIC="-latomic" (...)

2 years agogh-109207: Fix SystemError when printing symtable entry object. (GH-109225)
云line [Sun, 10 Sep 2023 12:04:24 +0000 (20:04 +0800)] 
gh-109207: Fix SystemError when printing symtable entry object. (GH-109225)

2 years agoFix "FSTRING_MIDDLE" typo in py312 "What's New" (#109222)
Delgan [Sun, 10 Sep 2023 10:55:56 +0000 (12:55 +0200)] 
Fix "FSTRING_MIDDLE" typo in py312 "What's New" (#109222)

2 years agogh-93627: Align Python implementation of pickle with C implementation of pickle ...
Pieter Eendebak [Sun, 10 Sep 2023 07:06:08 +0000 (09:06 +0200)] 
gh-93627: Align Python implementation of pickle with C implementation of pickle (GH-103035)

If a method like __reduce_ex_ or __reduce__ is set to None, a TypeError is raised.

2 years agogh-109174: Add support of SimpleNamespace in copy.replace() (GH-109175)
Serhiy Storchaka [Sun, 10 Sep 2023 05:09:25 +0000 (08:09 +0300)] 
gh-109174: Add support of SimpleNamespace in copy.replace() (GH-109175)

2 years agogh-109162: libregrtest: add Logger class (#109212)
Victor Stinner [Sun, 10 Sep 2023 03:04:26 +0000 (05:04 +0200)] 
gh-109162: libregrtest: add Logger class (#109212)

* Add Logger class in a new logger.py file.
* Move Regrtest attributes to Logger:

  * start_time
  * test_count_text
  * test_count_width
  * win_load_tracker

* Move Regrtest method to Logger:

  * log()
  * getloadavg(): rename to get_load_avg()
  * set_tests()

* Add methods to the Logger class:

  * start_load_tracker()
  * stop_load_tracker()

2 years agogh-109162: libregrtest: add TestResults class (#109208)
Victor Stinner [Sun, 10 Sep 2023 02:30:43 +0000 (04:30 +0200)] 
gh-109162: libregrtest: add TestResults class (#109208)

* Add TestResults class.
* Move Regrtest methods to TestResults:

  * accumulate_result(): now takes a RunTests parameter
  * get_executed()
  * no_tests_run()

* Add methods to TestResults:

  * add_junit()
  * display_result()
  * display_summary()
  * need_rerun()
  * prepare_rerun()
  * write_junit()

* Rename 'need_rerun' attribute to 'bad_results'.
* Rename 'total_stats' attribute to 'stats'.

2 years agogh-109162: Refactor libregrtest.Regrtest (#109206)
Victor Stinner [Sun, 10 Sep 2023 01:07:05 +0000 (03:07 +0200)] 
gh-109162: Refactor libregrtest.Regrtest (#109206)

* Add type hint types: TestName, StrPath, StrJSON.
* Add attributes to Regrtest:

  * cmdline_args
  * coverage
  * coverage_dir
  * fail_rerun
  * next_single_filename
  * print_slowest
  * tmp_dir
  * want_rerun
  * want_run_leaks

* Remove Regrtest.ns attribute.
* Rename Regrtest methods:

  * cleanup() => cleanup_temp_dir()
  * create_temp_dir() => make_temp_dir()
  * set_temp_dir() => select_temp_dir()

* Convert Regrtest methods to static methods:

  * cleanup_temp_dir()
  * display_header()
  * fix_umask()
  * get_rerun_match_tests()
  * list_tests()
  * make_temp_dir()
  * select_temp_dir()

* Remove display_sanitizers() method: move code into
  display_header().
* Rename 'test_cwd' variable to 'work_dir'.

2 years agogh-109162: Refactor libregrtest.runtest_mp (#109205)
Victor Stinner [Sun, 10 Sep 2023 00:24:38 +0000 (02:24 +0200)] 
gh-109162: Refactor libregrtest.runtest_mp (#109205)

* Add attributes to Regrtest and RunTests:

  * fail_env_changed
  * num_workers

* Rename MultiprocessTestRunner to RunWorkers. Add num_workers
  parameters to RunWorkers constructor. Remove RunWorkers.ns
  attribute.
* Rename TestWorkerProcess to WorkerThread.
* get_running() now returns a string like: "running (...): ...".
* Regrtest.action_run_tests() now selects the number of worker
  processes, instead of the command line parser.

2 years agogh-109162: libregrtest: remove WorkerJob class (#109204)
Victor Stinner [Sat, 9 Sep 2023 23:41:21 +0000 (01:41 +0200)] 
gh-109162: libregrtest: remove WorkerJob class (#109204)

* Add attributes to Regrtest and RunTests:

  * gc_threshold
  * memory_limit
  * python_cmd
  * use_resources

* Remove WorkerJob class. Add as_json() and from_json() methods to
  RunTests. A worker process now only uses RunTests for all
  parameters.
* Add tests on support.set_memlimit() in test_support. Create
  _parse_memlimit() and also adds tests on it.
* Remove 'ns' parameter from runtest.py.

2 years agogh-109162: libregrtest: fix _decode_worker_job() (#109202)
Victor Stinner [Sat, 9 Sep 2023 22:51:24 +0000 (00:51 +0200)] 
gh-109162: libregrtest: fix _decode_worker_job() (#109202)

Decode also HuntRefleak() object inside the RunTests object.

Add an unit test on huntrleaks with multiprocessing (-R -jN).

2 years agoImprove the sieve() recipe in the itertools docs (gh-109199)
Raymond Hettinger [Sat, 9 Sep 2023 22:50:04 +0000 (17:50 -0500)] 
Improve the sieve() recipe in the itertools docs (gh-109199)

Lazier sieve

2 years agoFix an ironic typo in a code comment. (gh-109186)
Raymond Hettinger [Sat, 9 Sep 2023 15:21:42 +0000 (10:21 -0500)] 
Fix an ironic typo in a code comment. (gh-109186)

2 years agogh-109162: Refactor libregrtest.RunTests (#109177)
Victor Stinner [Sat, 9 Sep 2023 09:18:14 +0000 (11:18 +0200)] 
gh-109162: Refactor libregrtest.RunTests (#109177)

* Rename dash_R() runtest_refleak(). The function now gets
  huntrleaks and quiet arguments, instead of 'ns' argument.
* Add attributes to Regrtest and RunTests:

  * verbose
  * quiet
  * huntrleaks
  * test_dir

* Add HuntRefleak class.

2 years agogh-109050: Remove remaining tests for legacy Unicode C API (GH-109068)
Serhiy Storchaka [Sat, 9 Sep 2023 05:44:46 +0000 (08:44 +0300)] 
gh-109050: Remove remaining tests for legacy Unicode C API (GH-109068)

2 years agogh-109118: Fix runtime crash when NameError happens in PEP 695 function (#109123)
Jelle Zijlstra [Sat, 9 Sep 2023 02:49:20 +0000 (19:49 -0700)] 
gh-109118: Fix runtime crash when NameError happens in PEP 695 function (#109123)

2 years agogh-109162: Refactor libregrtest.runtest (#109172)
Victor Stinner [Sat, 9 Sep 2023 01:37:48 +0000 (03:37 +0200)] 
gh-109162: Refactor libregrtest.runtest (#109172)

* Rename runtest() to run_single_test().
* Pass runtests to run_single_test().
* Add type annotation to Regrtest attributes. Add missing attributes
  to Namespace.
* Add attributes to Regrtest and RunTests:

  * fail_fast
  * ignore_tests
  * match_tests
  * output_on_failure
  * pgo
  * pgo_extended
  * timeout

* Get pgo from 'runtests', rather than from 'ns'.
* Remove WorkerJob.match_tests.
* setup_support() now gets pgo_extended from runtests.
* save_env(): change parameter order, pass test_name first.
* Add setup_test_dir() function.
* Pass runtests to setup_tests().

2 years agogh-109052: Use the base opcode when comparing code objects (gh-109107)
Tian Gao [Sat, 9 Sep 2023 01:24:49 +0000 (18:24 -0700)] 
gh-109052: Use the base opcode when comparing code objects (gh-109107)

2 years agogh-109162: Refactor libregrtest WorkerJob (#109171)
Victor Stinner [Sat, 9 Sep 2023 01:03:39 +0000 (03:03 +0200)] 
gh-109162: Refactor libregrtest WorkerJob (#109171)

* Rename --worker-args command line option to --worker-json.
* Rename _parse_worker_args() to _parse_worker_json().
* WorkerJob:

  * Add runtests attribute
  * Remove test_name and rerun attribute

* Rename run_test_in_subprocess() to create_worker_process().
* Rename run_tests_worker() to worker_process().
* create_worker_process() uses json.dump(): write directly JSON to
  stdout.
* Convert MultiprocessResult to a frozen dataclass.
* Rename RunTests.match_tests to RunTests.match_tests_dict.