Victor Stinner
926ff69f3f
gh-132825: Fix typo in dict_unhashable_type() name ( #132847 )
2025-04-23 18:54:13 +02:00
Victor Stinner
426449d983
gh-132825: Enhance unhashable error messages for dict and set ( #132828 )
2025-04-23 17:10:09 +02:00
Victor Stinner
dc3e9638c2
gh-132713: Fix typing.Union[index] race condition ( #132802 )
...
Add union_init_parameters() helper function. Use a critical section
to initialize the 'parameters' member.
2025-04-23 15:45:42 +02:00
Victor Stinner
de9deb7ca7
gh-132713: Simplify list_repr_impl() ( #132811 )
2025-04-23 08:59:30 +02:00
Victor Stinner
a4ea80d523
gh-132713: Fix repr(list) race condition ( #132801 )
...
Hold a strong reference to the item while calling repr(item).
2025-04-22 22:09:35 +02:00
Pablo Galindo Salgado
bf3a0a1c0f
gh-132449: Improve syntax error messages for keywords with typos ( #132450 )
...
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-04-22 11:01:55 +02:00
Peter Bierma
fa70bf8593
gh-132747: Fix NULL
dereference when calling a method's __get__
manually ( #132772 )
2025-04-21 14:09:34 -07:00
Sam Gross
da53660f35
gh-131586: Avoid refcount contention in context managers (gh-131851)
...
This avoid reference count contention in the free threading build
when calling special methods like `__enter__` and `__exit__`.
2025-04-21 15:54:25 -04:00
Sergey B Kirpichev
95800fe6e7
Correct _PyLong_Frexp() description in comments (GH-132716)
...
This amends d08c788822
, now this function always successful.
2025-04-19 07:42:20 +00:00
Kumar Aditya
4c3d187d9f
gh-126366: fix thread safety of dict key iterator ( #132693 )
2025-04-18 21:43:49 +05:30
Pieter Eendebak
e77d6784e7
gh-132657: Avoid locking in frozenset.__contains__ ( #132659 )
2025-04-18 20:20:29 +05:30
Bénédikt Tran
379352620c
gh-132097: use a macro for semantically casting function pointers ( #132406 )
2025-04-18 12:24:34 +02:00
Chris Eibl
80295a8f9b
GH-131296: fix clang-cl warning on Windows in Objects/longobject.c
for 32bit builds ( #131604 )
2025-04-18 10:45:30 +02:00
Jon Crall
fc0ec29889
gh-103997: Automatically dedent the argument to "-c" ( #103998 )
...
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Co-authored-by: Kirill Podoprigora <80244920+Eclips4@users.noreply.github.com>
Co-authored-by: Inada Naoki <songofacandy@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-04-18 17:39:30 +09:00
Tomasz Pytel
a23ed8b379
gh-132284: Don't wrap base PyCFunction slots on class creation if not overridden ( #132329 )
2025-04-17 18:08:59 +01:00
Sergey Miryanov
e42bda9441
gh-132042: Do not lookup tp_dict each time to speedup class creation ( #132619 )
2025-04-17 12:04:42 +02:00
Serhiy Storchaka
62ff86fa55
gh-130104: Call __rpow__ in ternary pow() if necessary (GH-130251)
...
Previously it was only called in binary pow() and the binary
power operator.
2025-04-16 18:32:41 +03:00
sobolevn
b6c552f9e6
gh-132176: Fix crash on type()
when tuple
subclass passed as bases
( #132212 )
...
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-04-15 14:13:51 +03:00
Bénédikt Tran
a81232c769
gh-132399: fix invalid function signatures on the free-threaded build ( #132400 )
2025-04-12 07:46:33 +00:00
Jelle Zijlstra
07b8d3117f
gh-132261: Store annotations at hidden internal keys in the class dict ( #132345 )
2025-04-10 21:13:26 -07:00
sobolevn
254110356d
gh-132285: Fix that __annotate__
is not deleted when __annotations__
is deleted ( #132286 )
2025-04-09 10:36:08 -07:00
Ken Jin
bd3aa0b9f7
gh-126703: Fix possible use after free in pycfunction freelist (GH-132319)
2025-04-09 22:49:33 +08:00
Kumar Aditya
ed99e28d5b
gh-132213: use relaxed atomics for set hash ( #132215 )
2025-04-07 21:59:24 +05:30
Jelle Zijlstra
9a6b702f3a
dictobject.c: Fix incorrect function name in errors ( #132193 )
2025-04-07 07:48:55 -07:00
Pieter Eendebak
dff8bcfa3c
gh-126703: Add freelist for range and range_iter objects (GH-128619)
2025-04-07 04:40:52 +08:00
Pieter Eendebak
29772b0647
gh-126703: Add PyCFunction freelist (GH-128692)
2025-04-05 23:51:05 +08:00
Kumar Aditya
76f6b5e64a
gh-132013: use relaxed atomics in hash of frozenset ( #132014 )
...
Use relaxed atomics in hash of `frozenset` to fix TSAN warning.
2025-04-02 20:01:05 +05:30
mpage
053c285f6b
gh-130704: Strength reduce LOAD_FAST{_LOAD_FAST}
( #130708 )
...
Optimize `LOAD_FAST` opcodes into faster versions that load borrowed references onto the operand stack when we can prove that the lifetime of the local outlives the lifetime of the temporary that is loaded onto the stack.
2025-04-01 10:18:42 -07:00
Bénédikt Tran
edbf7fb129
gh-111178: remove redundant casts for functions with correct signatures ( #131673 )
2025-04-01 17:18:11 +02:00
Chris Eibl
a175d64e30
GH-129149: Add fast path for medium-sized integers in PyLong_From*
functions ( #131211 )
...
Add a fast path for medium-sized integers in `PyLong_FromInt{32,64}` and `PyLong_FromUInt{32,64}`.
2025-03-30 10:12:42 +02:00
Dino Viehland
2984ff9e51
gh-130373: Avoid locking in _LOAD_ATTR_WITH_HINT ( #130372 )
...
Avoid locking in _LOAD_ATTR_WITH_HINT
2025-03-28 15:16:41 -07:00
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
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
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
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
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
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
Ageev Maxim
7c3692fe27
gh-130928: Fix error message during bytes formatting for the 'i'
flag ( #130967 )
2025-03-24 22:07:03 +03:00
Bénédikt Tran
4efe397d8e
gh-111178: fix UBSan failures for anextawaitableobject
( #131609 )
2025-03-24 14:43:48 +00:00
Sam Gross
da6730caa5
gh-128421: Avoid TSAN warnings in sys._current_frames()
(gh-131548)
...
This tells TSAN not to sanitize `PyUnstable_InterpreterFrame_GetLine()`.
There's a possible data race on the access to the frame's `instr_ptr`
if the frame is currently executing. We don't really care about the
race. In theory, we could use relaxed atomics for every access to
`instr_ptr`, but that would create more code churn and current compilers
are overly conservative with optimizations around relaxed atomic
accesses.
We also don't sanitize `_PyFrame_IsIncomplete()` because it accesses
`instr_ptr` and is called from assertions within PyFrame_GetCode().
2025-03-24 09:49:39 -04:00
Bénédikt Tran
a1205ef524
gh-111178: fix UBSan failures for PyBytesObject
( #131603 )
2025-03-24 11:02:09 +01:00
Bénédikt Tran
27f81e82df
gh-111178: fix UBSan failures for PyStdPrinter_Object
( #131607 )
2025-03-24 10:57:14 +01:00
Bénédikt Tran
aa444bc4af
gh-111178: fix UBSan failures for PyBufferWrapper
( #131616 )
2025-03-24 10:52:52 +01:00
Dino Viehland
d9411ae3c2
gh-130312: SET_ADD should not lock ( #130136 )
...
SET_ADD should not lock
2025-03-21 15:58:32 -07:00
Victor Stinner
7101cba6bf
gh-131238: Move _Py_VISIT_STACKREF() to pycore_stackref.h ( #131560 )
...
* Move _Py_VISIT_STACKREF() from pycore_gc.h to pycore_stackref.h.
* Remove pycore_interpframe.h include from pycore_genobject.h.
* Remove now useless includes from C files.
* Add pycore_interpframe_structs.h to Makefile.pre.in and
pythoncore.vcxproj.
2025-03-21 23:24:14 +01:00
Victor Stinner
61317074d4
gh-131238: Add pycore_interpframe_structs.h header ( #131553 )
...
Add an explicit include to pycore_interpframe_structs.h in
pycore_runtime_structs.h to fix a dependency cycle.
2025-03-21 17:19:47 +00:00
Victor Stinner
1a082085ae
gh-131238: Remove pycore_object_deferred.h from pycore_object.h ( #131549 )
...
Remove also pycore_function.h from pycore_typeobject.h.
2025-03-21 16:44:10 +00:00
Sam Gross
4f32516804
gh-128421: Add locking to most frame object functions (gh-131479)
...
This makes more operations on frame objects thread-safe in the free
threaded build, which fixes some data races that occurred when passing
exceptions between threads.
However, accessing local variables from another thread while its running
is still not thread-safe and may crash the interpreter.
2025-03-21 11:10:07 -04:00
Mark Shannon
7ebd71ee14
GH-131498: Remove conditional stack effects (GH-131499)
...
* Adds some missing #includes
2025-03-20 15:39:38 +00:00