Victor Stinner
c005ea4951
gh-129185: Use PyMutex in tracemalloc ( #129246 )
2025-01-24 11:25:24 +01:00
Bénédikt Tran
36bb229933
gh-129173: Use _PyUnicodeError_GetParams
in PyCodec_IgnoreErrors
( #129174 )
...
We also cleanup `PyCodec_StrictErrors` and the error message rendered
when an object of incorrect type is passed to codec error handlers.
2025-01-24 11:25:03 +01:00
Bénédikt Tran
25a614a502
gh-126004: Fix positions handling in codecs.backslashreplace_errors
( #127676 )
...
This fixes how `PyCodec_BackslashReplaceErrors` handles the `start` and `end`
attributes of `UnicodeError` objects via the `_PyUnicodeError_GetParams` helper.
2025-01-23 14:28:33 +01:00
Victor Stinner
e579cdb21e
gh-129185: Remove internal TRACE_RAW_MALLOC macro ( #129218 )
...
Always build tracemalloc with PyMem_RawMalloc() hooks.
2025-01-23 13:49:35 +01:00
Victor Stinner
46c7e13c05
gh-129185: Fix PyTraceMalloc_Untrack() at Python exit ( #129191 )
...
Support calling PyTraceMalloc_Track() and PyTraceMalloc_Untrack()
during late Python finalization.
* Call _PyTraceMalloc_Fini() later in Python finalization.
* Test also PyTraceMalloc_Untrack() without the GIL
* PyTraceMalloc_Untrack() now gets the GIL.
* Test also PyTraceMalloc_Untrack() in test_tracemalloc_track_race().
2025-01-23 12:07:34 +01:00
Bénédikt Tran
225296cd5b
gh-126004: Fix positions handling in codecs.replace_errors
( #127674 )
...
This fixes how `PyCodec_ReplaceErrors` handles the `start` and `end` attributes
of `UnicodeError` objects via the `_PyUnicodeError_GetParams` helper.
2025-01-23 11:44:18 +01:00
Bénédikt Tran
70dcc847df
gh-126004: Fix positions handling in codecs.xmlcharrefreplace_errors
( #127675 )
...
This fixes how `PyCodec_XMLCharRefReplaceErrors` handles the `start` and `end`
attributes of `UnicodeError` objects via the `_PyUnicodeError_GetParams` helper.
2025-01-23 11:42:38 +01:00
Sam Gross
a10f99375e
Revert "GH-128914: Remove conditional stack effects from bytecodes.c
and the code generators (GH-128918)" (GH-129202)
...
The commit introduced a ~2.5-3% regression in the free threading build.
This reverts commit ab61d3f430
.
2025-01-23 09:26:25 +00:00
Sergey B Kirpichev
d7d066c3ab
gh-127936, PEP 757: Convert marshal module to use import/export API for ints ( #128530 )
...
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-01-23 02:54:23 +00:00
Victor Stinner
0093a31273
gh-119182: Use public PyUnicodeWriter in Python-ast.c ( #129209 )
...
Replace the private _PyUnicodeWriter API with the public
PyUnicodeWriter API.
Use PyUnicodeWriter_WriteRepr() in ast_repr_list().
2025-01-23 00:57:37 +00:00
Victor Stinner
8eb9e76b5b
gh-119182: Use public PyUnicodeWriter in ast_unparse.c ( #129208 )
...
Replace the private _PyUnicodeWriter API with the public
PyUnicodeWriter API.
* Add append_char() function.
* Add APPEND_CHAR() and APPEND_CHAR_FINISH() macros.
* Replace APPEND_STR() and APPEND_STR_FINISH() of single character
with APPEND_CHAR() and APPEND_CHAR_FINISH().
2025-01-23 01:44:43 +01:00
Hood Chatham
960936fe90
gh-128627: Emscripten: Fix address calculation for wasm-gc trampoline ( #128782 )
...
Modifies the memory calculation to divide the entire memory address by 4, not just the base address.
2025-01-23 08:02:04 +08:00
Yury Selivanov
188598851d
GH-91048: Add utils for capturing async call stack for asyncio programs and enable profiling ( #124640 )
...
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
Co-authored-by: Jacob Coffee <jacob@z7x.org>
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2025-01-22 17:25:29 +01:00
Victor Stinner
9012fa741d
gh-128863: Deprecate private C API functions ( #128864 )
...
Deprecate private C API functions:
* _PyBytes_Join()
* _PyDict_GetItemStringWithError()
* _PyDict_Pop()
* _PyThreadState_UncheckedGet()
* _PyUnicode_AsString()
* _Py_HashPointer()
* _Py_fopen_obj()
Replace _Py_HashPointer() with Py_HashPointer().
Remove references to deprecated functions.
2025-01-22 11:04:19 +00:00
Mark Shannon
470a0a68eb
GH-128682: Change a couple of functions to only steal references on success. (GH-129132)
...
Change PyTuple_FromStackRefSteal and PyList_FromStackRefSteal to only steal on success to avoid escaping
2025-01-22 10:51:37 +00:00
Ken Jin
86c1a60d5a
gh-128563: Move GO_TO_INSTRUCTION and PREDICT to cases generator (GH-129115)
2025-01-22 09:22:25 +08:00
Ken Jin
5809b25909
gh-128563: Move lltrace into the frame struct (GH-129113)
2025-01-21 22:17:15 +08:00
Victor Stinner
31f149d5b3
gh-128679: Use _PyThreadState_GET() in tracemalloc.c ( #129126 )
...
Replace uncommon PyGILState_GetThisThreadState() with common
_PyThreadState_GET().
2025-01-21 14:43:31 +01:00
Victor Stinner
01de4af3e1
gh-126925: Make PyConfig.use_system_logger read-only ( #129124 )
...
The variable is only used once during early Python initialization, it
doesn't make sense to modify it at runtime.
2025-01-21 12:02:38 +01:00
Mark Shannon
f5b6356a11
GH-128563: Add new frame owner type for interpreter entry frames (GH-129078)
...
Add new frame owner type for interpreter entry frames
2025-01-21 10:15:02 +00:00
Mark Shannon
7239da7559
GH-127953: Make line number lookup O(1) regardless of the size of the code object (GH-128350)
2025-01-21 09:33:23 +00:00
Mark Shannon
ab61d3f430
GH-128914: Remove conditional stack effects from bytecodes.c
and the code generators (GH-128918)
2025-01-20 17:09:23 +00:00
Mark Shannon
f0f7b978be
GH-128939: Refactor JIT optimize structs (GH-128940)
2025-01-20 15:49:15 +00:00
Victor Stinner
8ceb6cb117
gh-129033: Remove _PyInterpreterState_SetConfig() function ( #129048 )
...
Remove _PyInterpreterState_GetConfigCopy() and
_PyInterpreterState_SetConfig() private functions. PEP 741 "Python
Configuration C API" added a better public C API: PyConfig_Get() and
PyConfig_Set().
2025-01-20 16:31:33 +01:00
Erlend E. Aasland
537296cdcd
gh-111178: Generate correct signature for most self converters ( #128447 )
2025-01-20 12:40:18 +01:00
Peter Bierma
4d0a6595a0
gh-128360: Add _Py_AssertHoldsTstate
as assertion for holding a thread state ( #128361 )
...
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-01-20 17:04:35 +05:30
Victor Stinner
07c3518ffb
gh-129033: Remove _Py_InitializeMain() function ( #129034 )
...
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
2025-01-20 10:03:22 +00:00
Kirill Podoprigora
6c52ada551
gh-100239: Handle NaN and zero division in guards for BINARY_OP_EXTEND
( #128963 )
...
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2025-01-19 11:02:49 +00:00
mpage
13c4def692
gh-128955: Fix goto if tlbc creation fails when throwing into a generator ( #128957 )
...
We don't have the correct copy of the bytecode and can't update next_instr
appropriately, so just unwind.
2025-01-17 12:53:29 -08:00
Sam Gross
d66c08aa75
gh-128923: Use zero to indicate unassigned unique id ( #128925 )
...
In the free threading build, the per thread reference counting uses a
unique id for some objects to index into the local reference count
table. Use 0 instead of -1 to indicate that the id is not assigned. This
avoids bugs where zero-initialized heap type objects look like they have
a unique id assigned.
2025-01-17 16:42:27 +01:00
Xuanteng Huang
b44ff6d0df
GH-126599: Remove the "counter" optimizer/executor (GH-126853)
2025-01-16 15:57:04 -08:00
Irit Katriel
3893a92d95
gh-100239: specialize long tail of binary operations ( #128722 )
2025-01-16 15:22:13 +00:00
Victor Stinner
3193cb5ef8
gh-128679: Fix tracemalloc.stop() race conditions ( #128893 )
...
tracemalloc_alloc(), tracemalloc_realloc(), tracemalloc_free(),
_PyTraceMalloc_TraceRef() and _PyTraceMalloc_GetMemory() now check
'tracemalloc_config.tracing' after calling TABLES_LOCK().
_PyTraceMalloc_TraceRef() now always returns 0.
2025-01-16 13:53:18 +01:00
Victor Stinner
36c5e3bcc2
gh-128679: Redesign tracemalloc locking ( #128888 )
...
* Use TABLES_LOCK() to protect 'tracemalloc_config.tracing'.
* Hold TABLES_LOCK() longer while accessing tables.
* tracemalloc_realloc() and tracemalloc_free() no longer
remove the trace on reentrant call.
* _PyTraceMalloc_Stop() unregisters _PyTraceMalloc_TraceRef().
* _PyTraceMalloc_GetTraces() sets the reentrant flag.
* tracemalloc_clear_traces_unlocked() sets the reentrant flag.
2025-01-15 20:22:44 +00:00
Neil Schemenauer
080f444a58
gh-128807: Add marking phase for free-threaded cyclic GC (gh-128808)
2025-01-15 11:27:28 -08:00
mpage
b5ee0258bf
gh-115999: Specialize LOAD_ATTR
for instance and class receivers in free-threaded builds ( #128164 )
...
Finish specialization for LOAD_ATTR in the free-threaded build by adding support for class and instance receivers.
2025-01-14 11:56:11 -08:00
Neil Schemenauer
1c13c56a34
gh-128384: Add locking to warnings.py. (gh-128386)
...
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-01-14 11:43:42 -08:00
Mark Shannon
f49a1df6f3
GH-128682: Convert explicit loops closing arrays into DECREF_INPUTS
. (GH-128822)
...
* Mark Py_DECREF and Py_XDECREF as escaping
* Remove explicit loops for clearing array inputs
2025-01-14 15:08:56 +00:00
Peter Bierma
bf64a582f0
gh-128400: Only show the current thread in Py_FatalError
on the free-threaded build ( #128758 )
2025-01-13 20:06:54 +05:30
Mark Shannon
517dc65ffc
GH-128682: Stronger checking of PyStackRef_CLOSE
and DEAD
. (GH-128683)
2025-01-13 12:37:48 +00:00
Mark Shannon
ddd959987c
GH-128685: Specialize (rather than quicken) LOAD_CONST into LOAD_CONST_[IM]MORTAL (GH-128708)
2025-01-13 10:30:28 +00:00
Hood Chatham
d0ecbdd838
gh-128627: Emscripten: Use wasm-gc based call adaptor if available ( #128628 )
...
Replaces the trampoline mechanism in Emscripten with an implementation that uses a
recently added feature of wasm-gc instead of JS type reflection, when that feature is
available.
2025-01-13 07:09:39 +08:00
Peter Bierma
f6c61bf2d7
gh-128717: Stop-the-world when setting the recursion limit ( #128741 )
2025-01-12 18:34:30 +05:30
9cel
3a570c6d58
Make the Python CLI error message style more consistent (GH-128129)
2025-01-11 11:17:35 +02:00
Bénédikt Tran
28ffdc5702
gh-111178: fix UBSan failures in Python/bltinmodule.c
(GH-128235)
...
* fix UBSan failures for `filterobject`
* fix UBSan failures for `mapobject`
* fix UBSan failures for `zipobject`
2025-01-10 11:51:24 +01:00
Petr Viktorin
1439b81928
gh-128629: Add Py_PACK_VERSION and Py_PACK_FULL_VERSION (GH-128630)
2025-01-09 11:10:28 +01:00
Brandt Bucher
004f9fd1f2
Remove unnecessary LIST_TO_TUPLE conversions (GH-126558)
2025-01-08 09:00:11 -08:00
Bénédikt Tran
1da0901894
gh-111178: fix UBSan failures in Python/context.c
(GH-128242)
...
* fix UBSan failures for `PyContext`
* fix UBSan failures for `PyContextVar`
* fix UBSan failures for `PyContextToken`
* fix UBSan failures for `_PyContextTokenMissing`
2025-01-08 14:52:27 +01:00
Bénédikt Tran
c22302ecea
gh-111178: fix UBSan failures in Python/hamt.c
(GH-128247)
...
* fix UBSan failures for `PyHamtObject`
* fix UBSan failures for `PyHamtNode_Array`
* fix UBSan failures for `PyHamtNode_Collision`
* fix UBSan failures for `PyHamtNode_Bitmap`
2025-01-08 14:50:40 +01:00
Brandt Bucher
65ae3d5a73
GH-127809: Fix the JIT's understanding of ** (GH-127844)
2025-01-07 17:25:48 -08:00