126144 Commits

Author SHA1 Message Date
Irit Katriel
2c8f329dc6
gh-131738: optimize builtin any/all/tuple calls with a generator expression arg (#131737) 2025-03-28 10:35:20 +00:00
Yan Yanchii
674dbf3b3a
gh-126835: Refine constant folding tests in test_peepholer.py::TestTranforms (#131826) 2025-03-28 10:10:22 +00:00
Hang
8bd88e2827
gh-131818: Add imply -P in -I's help message (#131819) 2025-03-28 08:49:13 +01:00
Victorien
af2afd7c22
gh-119180: Use equality when comparing against annotationlib.Format (#131755) 2025-03-27 21:56:09 -07:00
Thomas Grainger
8a00c9a4d2
gh-128770: raise warnings as errors in test suite - except for test_socket which still logs warnings, and internal test warnings that are now logged (#128973)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-27 21:06:52 +02:00
Brandt Bucher
972a295fe3
GH-130415: Remove redundant sym_matches_type calls in the JIT optimizer (GH-131778) 2025-03-27 09:12:30 -07:00
Wulian233
a096a41b92
gh-128438: Use EnvironmentVarGuard for datetimetester.py to manage environment varibales (#130002) 2025-03-27 18:07:09 +02:00
Semyon Moroz
9b83670f0f
gh-131178: Add tests for tokenize command-line interface (#131274) 2025-03-27 18:04:16 +02:00
Michael Droettboom
8614f86b71
gh-131525: Cache the result of tuple_hash (#131529)
* gh-131525: Cache the result of tuple_hash

* Fix debug builds

* Add blurb

* Fix formatting

* Pre-compute empty tuple singleton

* Mostly set the cache within tuple_alloc

* Fixes for TSAN

* Pre-compute empty tuple singleton

* Fix for 32-bit platforms

* Assert that op != NULL in _PyTuple_RESET_HASH_CACHE

* Use FT_ATOMIC_STORE_SSIZE_RELAXED macro

* Update Include/internal/pycore_tuple.h

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Fix alignment

* atomic load

* Update Objects/tupleobject.c

Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
2025-03-27 09:57:06 -04:00
Semyon Moroz
cf5e438c02
gh-118761: Always lazy import re in locale (#129860) 2025-03-27 15:47:08 +02:00
Victor Stinner
3796884528
gh-111178: Skip undefined behavior checks in _PyPegen_lookahead() (#131714)
For example, expression_rule() return type is 'expr_ty', whereas
_PyPegen_lookahead() uses 'void*'.
2025-03-27 10:03:58 +01:00
Victor Stinner
9ef9d687ff
gh-131712: Build _suggestions extension on Windows (#131759)
Add a test checking that the '_suggestions' extension is available.
2025-03-27 09:53:39 +01:00
Mark Shannon
d836d287a7
GH-131729: Consider in-memory state when merging storage and stack (GH-131773) 2025-03-27 08:32:45 +00:00
Neil Schemenauer
316938bddf
Revise pycore_stackref.h comments. (#130601) 2025-03-27 14:00:25 +05:30
Neil Schemenauer
c824d8e6f9
gh-131782: Fix cast to match type of bits in _Py_TryIncrefCompareStackRef (#131783) 2025-03-27 13:58:59 +05:30
Sergey Muraviov
151d1bfd1b
gh-131763: Replace the redundant check with assert in remove_tools (#131765) 2025-03-26 18:36:04 -04:00
Simon Legner
52b5eb95b7
gh-131236: allow to generate multiple UUIDs at once via CLI (#131218)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-26 22:49:28 +02:00
Brandt Bucher
4b3d5b6042
GH-119866: Don't clear frame->stackpointer on release builds (GH-131750) 2025-03-26 19:00:16 +00:00
rialbat
2c686a9ac2
gh-131762: Fixed dereferencing the pointer 'parser_token->metadata' with a NULL value (#131764) 2025-03-26 18:44:56 +00:00
Sam Gross
67fbfb42bd
gh-131586: Avoid refcount contention in some "special" calls (#131588)
In the free threaded build, the `_PyObject_LookupSpecial()` call can lead to
reference count contention on the returned function object becuase it
doesn't use stackrefs. Refactor some of the callers to use
`_PyObject_MaybeCallSpecialNoArgs`, which uses stackrefs internally.

This fixes the scaling bottleneck in the "lookup_special" microbenchmark
in `ftscalingbench.py`. However, the are still some uses of
`_PyObject_LookupSpecial()` that need to be addressed in future PRs.
2025-03-26 14:38:47 -04:00
Sam Gross
3d4ac1a2c2
gh-123358: Use _PyStackRef in LOAD_DEREF (gh-130064)
Concurrent accesses from multiple threads to the same `cell` object did not
scale well in the free-threaded build. Use `_PyStackRef` and optimistically
avoid locking to improve scaling.

With the locks around cell reads gone, some of the free threading tests were
prone to starvation: the readers were able to run in a tight loop and the
writer threads weren't scheduled frequently enough to make timely progress.
Adjust the tests to avoid this.

Co-authored-by: Donghee Na <donghee.na@python.org>
2025-03-26 12:08:20 -04:00
Mark Shannon
1b8bb1ed0c
GH-131729: Code-gen better liveness analysis (GH-131732)
* Rename 'defined' attribute to 'in_local' to more accurately reflect how it is used

* Make death of variables explicit even for array variables.

* Convert in_memory from boolean to stack offset

* Don't apply liveness analysis to optimizer generated code

* Fix RETURN_VALUE in optimizer
2025-03-26 15:21:35 +00:00
Idan Noiman
b9ca438daa
gh-131741: Add documentation for Windows version detection change in platform (#131742)
Document the behavior change between 3.11 & 3.12, where ``platform`` now correctly detects Windows 11 and Windows Server releases past Windows Server 2012.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Wulian <1055917385@qq.com>
2025-03-26 14:50:37 +00:00
Thomas Grainger
2d83891dfd
gh-131649: fix test_string_literals SyntaxWarning (#131650) 2025-03-26 15:01:18 +01:00
Sam Gross
5abff6960b
gh-117657: Fix data race in compare_unicode_unicode_threadsafe (gh-131746)
We can't safely check the type of the found key until we incref it or if we know that it's immortal.
2025-03-26 09:01:57 -04:00
Ralf Gommers
ac12de2e6a
document that sys._is_gil_enabled is CPython-specific (#131748) 2025-03-26 17:32:52 +05:30
Jelle Zijlstra
898e6b395e
gh-130881: Handle conditionally defined annotations (#130935) 2025-03-26 03:48:19 +00:00
Donghee Na
7bb41aef4b
gh-131740: Update PyUnstable_GC_VisitObjects to traverse perm gen (gh-131744) 2025-03-26 09:45:29 +09:00
Bojun Ren
a26a301f8b
GH-130673: Gracefully handle missing sections in JIT build (GH-130906) 2025-03-25 16:35:39 -07:00
Chris Eibl
488174dc68
GH-131691: Fix exception handling setting for clang-cl on Windows (GH-131730)
The /EHa option for Clang-CL behaves differently than the same option for MSVC, which is why we don't use it for both compilers.
2025-03-25 23:07:52 +00:00
Peter Bierma
90b82f2b61
gh-129900: Fix SystemExit return codes when the REPL is started from the command line (#129901) 2025-03-25 19:48:46 +00:00
Thomas Grainger
8ada7a9e14
gh-131647: fix 'sys.path_hooks is empty' warning in test_importlib (#131648) 2025-03-25 18:16:15 +01:00
Diego Russo
ea0453ee97
GH-130887: Always remove trailing jumps in AArch64 JIT stencils (GH-131042) 2025-03-25 10:15:36 -07:00
Tomasz Pytel
0a91456ad1
gh-131719: add NULL pointer check to _PyMem_FreeDelayed (gh-131720) 2025-03-25 10:49:18 -04:00
Sergey Muraviov
44605aa93d
gh-131711: Preventing the use of a null pointer in set_tp_mro (#131713) 2025-03-25 14:28:38 +01:00
Kumar Aditya
f1967e7249
gh-127945: fix thread safety of ctypes state (#131710)
This fixes thread safety of `array_cache` and `swapped_suffix` by initializing them in module exec to make it thread safety.
2025-03-25 17:03:05 +05:30
Kumar Aditya
96ef4c511f
gh-127945: add locking to malloc closure in free-threading (#131662)
The freelist is not thread safe in free-threading so this adds lock around it make it thread safe in free-threading.
2025-03-25 16:48:46 +05:30
Thomas Grainger
6fb5f7f4d9
gh-131707: fix unawaited coroutine warning in test_coroutines.Corouti… (#131708)
gh-131707: fix unawaited coroutine warning in test_coroutines.CoroutineTest.test_17
2025-03-25 08:29:51 +00:00
Adam Turner
7d9442f0d5
gh-128446: Run Windows CI tests on each commit (#131702) 2025-03-25 09:06:15 +02:00
Bénédikt Tran
1393bd3548
gh-131666: mark anext_awaitable.close as a METH_NOARGS instead of METH_VARARGS (#131671) 2025-03-25 09:03:22 +05:30
Chris Eibl
c3b8d73208
GH-131473: Override PreferredToolArchitecture when using Visual Studio bundled clang-cl (GH-131689)
tweak PreferredToolArchitecture for bundled clang-cl
2025-03-24 23:15:51 +00:00
Hood Chatham
97ab8fc16a
gh-127146: Fix Emscripten build with --pydebug (#131672)
Removes an explicit check that sysconfigdata naming is correct, in favor of reporting at
runtime with the default mechanisms.
2025-03-25 05:43:31 +08:00
Sam Gross
a123245986
gh-131677: Fix flaky test_lru_cache_threaded3 (gh-131679)
The call to `with self.subTest(...)` was not thread-safe.
2025-03-24 16:41:50 -04:00
Ageev Maxim
7c3692fe27
gh-130928: Fix error message during bytes formatting for the 'i' flag (#130967) 2025-03-24 22:07:03 +03:00
sobolevn
929afd1d6e
gh-131670: Fix crash in anext() when __anext__ is sync and raises (#131682)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-24 19:00:48 +00:00
Victor Stinner
5fef4ff9ed
gh-111178: Fix function signature in pyexpat.c (#131674)
Move _Py_NO_SANITIZE_UNDEFINED macro from faulthandler.c to pyport.h.
2025-03-24 17:22:45 +00:00
Chris Eibl
d16f455cd8
GH-131521: Uses correct build flags for zlib-ng on Windows (GH-131526)
Do not enable AdvancedVectorExtensions2 for all *.c files, so that the resulting binary can be executed on older CPUs, too. Also enable AdvancedVectorExtensions512 where necessary, and add the ClangCL flags required to enable vector extensions.
2025-03-24 16:21:57 +00:00
Bénédikt Tran
1d6a2e6481
gh-111178: fix UBSan for example code in extending/newtypes_tutorial docs (GH-131606)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-03-24 17:15:32 +01:00
Barney Gale
d372472896
GH-128520: pathlib ABCs: tighten up argument types (#131621)
In `JoinablePath.full_match()` and `ReadablePath.glob()`, accept a `str`
pattern argument rather than `JoinablePath | str`.

In `ReadablePath.copy()` and `copy_into()`, accept a `WritablePath` target
argument rather than `WritablePath | str`.
2025-03-24 15:39:08 +00:00
David Lowry-Duda
d2d886215c
gh-115684: Clarify datetime replace documentation (#116519)
* Clarify datetime `replace` documentation

In #115684, HopedForLuck noted that `datetime.date.replace()`
documentation was confusing because it looked like it would be changing
immutable objects.

This documentation change specifies that the `replace()` methods in
`datetime` return new objects. This uses similar wording to the
documentation for `datetime.combine()`, which specifies that a new
datetime is returned. This is also similar to wording for
`string.replace()`, except `string.replace()` emphasizes that a "copy"
is returned.

Resolves #115684.

* Include reviewer comments

Thanks Privat33r-dev for the comments!

---------

Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
2025-03-24 11:33:16 -04:00