Commit graph

9946 commits

Author SHA1 Message Date
Serhiy Storchaka
ad0a3f733b
gh-131927: Do not emit PEP 765 warnings in ast.parse() (GH-139642)
ast.parse() no longer emits syntax warnings for
return/break/continue in finally (see PEP-765) -- they are only
emitted during compilation.
2025-10-30 13:00:42 +02:00
Victor Stinner
80f20f58b2
gh-125434: Fix non-ASCII thread names in faulthandler on Windows (#140700)
Add _Py_DumpWideString() function to dump a wide string as ASCII. It
supports surrogate pairs.

Replace _Py_EncodeLocaleRaw() with _Py_DumpWideString()
in write_thread_name().
2025-10-28 14:41:51 +01:00
Peter Bierma
2cefa70eb9
gh-140544: Always assume that thread locals are available (GH-140690)
Python has required thread local support since 3.12 (see GH-103324). By assuming that thread locals are always supported, we can improve the performance of third-party extensions by allowing them to access the attached thread and interpreter states directly.
2025-10-28 09:07:19 -04:00
Ken Jin
a716091227
gh-140104: Set next_instr properly in the JIT during exceptions (GH-140233)
Co-authored-by: devdanzin <74280297+devdanzin@users.noreply.github.com>
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
2025-10-27 18:26:47 +00:00
Victor Stinner
313145eab5
gh-125434: Display thread name in faulthandler on Windows (#140675) 2025-10-27 18:41:18 +01:00
alm
1753ccb432
gh-138050: [WIP] JIT - Streamline MAKE_WARM - move coldness check to executor creation (GH-138240) 2025-10-27 16:37:37 +00:00
Itamar Oren
e8b5cb8f33
gh-140641: Break out of inittab search on match (GH-140642) 2025-10-27 15:18:58 +02:00
Kumar Aditya
ef4665f918
gh-140544: store pointer to interpreter state as a thread local for fast access (#140573) 2025-10-25 19:56:07 +05:30
Tapeline
4f8e7b5ac5
gh-136327: Fix inconsistent `TypeError` messages regarding invalid values after * and ** (#136395) 2025-10-24 19:12:49 +00:00
Mikhail Efimov
be5af997f3
gh-140517: fix leak in map_next in strict mode (#140543) 2025-10-24 21:29:16 +05:30
Kumar Aditya
ebf9938496
gh-140544: cleanup HAVE_THREAD_LOCAL checks in pystate.c (#140547) 2025-10-24 14:23:06 +00:00
Mikhail Efimov
918a9ac9f4
gh-135125: Fix Py_STACKREF_DEBUG build (GH-139475)
* Use the same pattern of refcounting for stackrefs as in production build
2025-10-23 17:00:23 +01:00
Stan Ulbrych
95953b692d
gh-140471: Fix buffer overflow in AST node initialization with malformed _fields (#140506) 2025-10-23 15:35:21 +00:00
Sergey Miryanov
a4709e525f
GH-139193: Fix dump_stack when PYTHON_LLTRACE=4 (GH-139384) 2025-10-22 14:14:25 +01:00
Mark Shannon
0c01090ad9
GH-139951: Fix major GC performance regression (GH-140262)
* Count number of actually tracked objects, instead of trackable objects. This ensures that untracking tuples has the desired effect of reducing GC overhead

* Do not track most untrackable tuples during creation. This prevents large numbers of small tuples causing execessive GCs.
2025-10-21 15:22:15 +01:00
Pål Grønås Drange
b2f9fb9db2
gh-140358: Bring back elapsed time and unreachable count to gc debug output (#140359) 2025-10-21 00:54:44 +01:00
Shamil
a615fb49c9
gh-140301: Fix memory leak in subinterpreter PyConfig cleanup (#140303)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-10-20 09:29:23 +00:00
Shamil
f9323213c9
gh-140306: Fix memory leaks in cross-interpreter data handling (GH-140307) 2025-10-19 22:24:28 +03:00
Shamil
bedaea0598
gh-139269: Fix unaligned memory access in JIT code patching functions (GH-139271)
* Use memcpy for patching values instead of direct assignment


Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-10-19 00:20:04 +01:00
Kumar Aditya
58c44c2bf2
gh-140067: Fix memory leak in sub-interpreter creation (#140111) (#140261)
Fix memory leak in sub-interpreter creation caused by overwriting of the previously used `_malloced` field. Now the pointer is stored in the first word of the memory block to avoid it being overwritten accidentally. 

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-10-18 16:36:58 +05:30
Shamil
c8729c9909
gh-140257: fix data race on eval_breaker during finalization (#140265) 2025-10-18 16:31:53 +05:30
Mark Shannon
f1883852ed
GH-135904: Implement assembler optimization for AArch64. (GH-139855) 2025-10-17 11:26:17 +01:00
Sergey Miryanov
32c264982e
gh-140061: Use _PyObject_IsUniquelyReferenced() to check if objects are uniquely referenced (gh-140062)
The previous `Py_REFCNT(x) == 1` checks can have data races in the free
threaded build. `_PyObject_IsUniquelyReferenced(x)` is a more conservative
check that is safe in the free threaded build and is identical to
`Py_REFCNT(x) == 1` in the default GIL-enabled build.
2025-10-15 09:48:21 -04:00
Peter Bierma
0bcb1c25f7
Revert "gh-140067: Fix memory leak in sub-interpreter creation (#140111)" (#140140)
This reverts commit 59547a251f.
2025-10-15 07:16:43 +05:30
Maurycy Pawłowski-Wieroński
3490a99046
Correct a simple NULL-check in optimizer.c's uop_item() (GH-140069) 2025-10-14 16:18:20 +01:00
Serhiy Storchaka
279db6bede
gh-139640: Fix swallowing syntax warnings in different modules (GH-139755)
Revert GH-131993.

Fix swallowing some syntax warnings in different modules if they accidentally
have the same message and are emitted from the same line.
2025-10-14 17:48:09 +03:00
Shamil
59547a251f
gh-140067: Fix memory leak in sub-interpreter creation (#140111)
Fix memory leak in sub-interpreter creation caused by overwriting of the previously used `_malloced` field. Now the pointer is stored in the first word of the memory block to avoid it being overwritten accidentally. 

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-10-14 14:42:17 +00:00
Victor Stinner
166cdaa6fb
gh-111489: Remove _PyTuple_FromArray() alias (#139973)
Replace _PyTuple_FromArray() with PyTuple_FromArray().
Remove pycore_tuple.h includes.
2025-10-11 22:58:14 +02:00
Bénédikt Tran
b04a57deef
gh-139748: fix leaks in AC error paths when using unicode FS-based converters (#139765) 2025-10-08 20:52:44 +05:30
Victor Stinner
3d3f126e86
gh-139353: Rename formatter_unicode.c to unicode_formatter.c (#139723)
* Move Python/formatter_unicode.c to Objects/unicode_formatter.c.
* Move Objects/stringlib/localeutil.h content into
  unicode_formatter.c. Remove localeutil.h.
* Move _PyUnicode_InsertThousandsGrouping() to unicode_formatter.c
  and mark the function as static.
* Rename unicode_fill() to _PyUnicode_Fill() and export it in
  pycore_unicodeobject.h.
* Move MAX_UNICODE to pycore_unicodeobject.h as _Py_MAX_UNICODE.
2025-10-08 14:56:00 +02:00
Mark Shannon
7094f09f54
GH-139291: Fix C stack limits by factoring out finding hardware stack limits (GH-139294) 2025-10-07 15:04:37 +02:00
Dino Viehland
ff0cf0af10
gh-139525: Don't specialize functions which have a modified vectorcall (#139524)
Don't specialize functions which have a modified vectorcall
2025-10-03 09:58:32 -07:00
Stan Ulbrych
12805ef9da
Python/codecs.c: Remove unused forward declaration (#139511) 2025-10-03 13:33:49 +02:00
Sergey Miryanov
e6e376a760
gh-132042: Remove resolve_slotdups() to speedup class creation (#132156)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-10-03 11:58:00 +02:00
Victor Stinner
536787591a
Fix typo in tracemalloc.c (#139450) 2025-10-01 08:58:18 +02:00
Petr Viktorin
01157e0cdf
gh-139116: tracemalloc: Detach thread state when acquiring tables_lock (GH-139449)
* gh-139116: tracemalloc: Detach thread state when acquiring tables_lock

This prevents a deadlock when:

- One thread is in `_PyTraceMalloc_Stop`, with `TABLES_LOCK` held, calling
  `PyRefTracer_SetTracer` which wants to stop the world
- Another is thread in `PyTraceMalloc_Track`, just attached thread state, waiting
  for `TABLES_LOCK`

Detaching the thread state while waiting for `TABLES_LOCK` allows
`PyRefTracer_SetTracer` to stop the world.


Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-09-30 16:43:49 +02:00
Pablo Galindo Salgado
1963e70100
gh-139275: Fix compilation of Modules/_remote_debugging_module.c when the system doesn't have process_vm_readv (#139307) 2025-09-25 00:16:44 +01:00
Rok Mandeljc
7016044de9
gh-139231: Fix estimation of available stack size for recursion limit on macOS (GH-139232)
Use `pthread_get_stackaddr_np()` and `pthread_get_stacksize_np()` to determine the stack address and size.
2025-09-24 11:57:00 +01:00
Donghee Na
c4f21d7c7c
gh-133171: Re-enable JUMP_BACKWARD to free-threading build (gh-137800) 2025-09-24 14:19:17 +09:00
Serhiy Storchaka
1a2e00c97a
gh-67795: Accept any real numbers as timestamp and timeout (GH-139224)
Functions that take timestamp or timeout arguments now accept any
real numbers (such as Decimal and Fraction), not only integers or floats,
although this does not improve precision.
2025-09-23 21:31:42 +03:00
Victor Stinner
e8382e55c5
gh-74857, PEP 538: Coerce POSIX locale to UTF-8 based locale (#139238) 2025-09-23 19:20:59 +02:00
Peter Bierma
d06113c7a7
gh-112729: Correctly fail when the process is out of memory during interpreter creation (GH-139164) 2025-09-19 10:41:09 -04:00
Lisa Roach
2fd43a1ffe
gh-138310: Adds sys.audit event for import_module (#138311)
* Updates sys.audit calls for imports to include import_module
* Adds unit tests for existing and new functionality
2025-09-19 06:21:42 -07:00
Peter Bierma
9243a4b933
gh-126016: Remove bad assertion in PyThreadState_Clear (GH-139158)
In the _interpreters module, we use PyEval_EvalCode() to run Python code in another interpreter. However, when the process receives a KeyboardInterrupt, PyEval_EvalCode() will jump straight to finalization rather than returning. This prevents us from cleaning up and marking the thread as "not running main", which triggers an assertion in PyThreadState_Clear() on debug builds. Since everything else works as intended, remove that assertion.
2025-09-19 12:17:05 +00:00
Peter Bierma
3eec897752
gh-136003: Skip non-daemon threads when exceptions occur during finalization (GH-139129)
During finalization, we need to mark all non-daemon threads as daemon to quickly shut down threads when sending CTRL^C to the process. This was a minor regression from GH-136004.
2025-09-18 16:04:01 -04:00
Ken Jin
a269e691de
gh-139109: Dynamic opcode targets (GH-139111)
Make opcode targets table dynamic
2025-09-18 14:12:07 +01:00
Victor Stinner
6504f20cce
gh-135755: Make Py_TAIL_CALL_INTERP macro private (#138981)
Rename Py_TAIL_CALL_INTERP to _Py_TAIL_CALL_INTERP.
2025-09-18 14:33:07 +02:00
Peter Bierma
2191497933
gh-136003: Execute pre-finalization callbacks in a loop (GH-136004) 2025-09-18 08:29:12 -04:00
Mark Shannon
3b83257366
GH-138378: Move globals-to-consts pass into main optimizer pass (GH-138379) 2025-09-18 10:09:59 +01:00
Donghee Na
d873fb42f3
gh-137838: Move _PyUOpInstruction buffer to PyInterpreterState (gh-138918) 2025-09-17 18:50:16 +01:00