cpython/Python
Neil Schemenauer cdba68e563
[3.15] gh-159136: Avoid stop-the-world when setting function name attributes (gh-159269) (gh-159725)
Setting __name__, __qualname__, __doc__ or __module__ on a function
stopped the world in the free-threaded build since gh-154826 and
gh-154851, making functools.wraps() orders of magnitude slower with
multiple threads.

Use the per-object critical section and _PyObject_XSetRefDelayed()
instead, as gen_set_name() already does.  Use acquire loads in the
readers and hold strong references across error reporting, tracing, and
eval-frame recording that may execute Python or detach the thread.  The
__code__, __defaults__, __kwdefaults__ and __closure__ setters still
stop the world to clear func_version.

Document synchronization requirements for direct field access and the
lifetime of borrowed function attributes.

(cherry picked from commit 010bebbf9f)
2026-10-29 15:17:50 -07:00
..
clinic [3.15] gh-142349: Simplify lazy import resolution (GH-158282) (#158569) 2026-10-01 16:56:39 +00:00
frozen_modules
_contextvars.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
_warnings.c [3.15] gh-159739: Fix reference and error handling in warnings (GH-159758) (#160022) 2026-10-21 11:55:12 -07:00
asdl.c bpo-43244: Remove ast.h, asdl.h, Python-ast.h headers (GH-24933) 2021-03-23 20:47:40 +01:00
asm_trampoline.S [3.15] gh-128883: Store ELF perf trampoline templates in read-only data (GH-160366) (#160490) 2026-10-23 21:01:06 +00:00
asm_trampoline_aarch64.h [3.15] gh-139808: Add branch protections for aarch64 in asm_trampoline.S (GH-130864) (#149730) 2026-05-12 22:10:24 +02:00
assemble.c [3.15] gh-151112: Fix double free in assemble_init when out of memory (GH-151142) (#151205) 2026-06-09 20:16:42 +00:00
ast.c [3.15] gh-152708: Fix AST generation asymmetry for unary positive in match statements (GH-152712) (#158079) 2026-09-24 23:51:39 +01:00
ast_preprocess.c [3.15] gh-152708: Fix AST generation asymmetry for unary positive in match statements (GH-152712) (#158079) 2026-09-24 23:51:39 +01:00
ast_unparse.c gh-143055: Fix crash in AST unparser when unparsing dict comprehension unpacking (#145556) 2026-03-09 10:37:23 -07:00
bltinmodule.c [3.15] gh-152132: Test Py_CompileString() in test_capi.test_run (GH-153470) (#153472) 2026-07-10 02:07:38 +00:00
bootstrap_hash.c GH-131238: Core header refactor (GH-131250) 2025-03-17 09:19:04 +00:00
brc.c [3.15] gh-157838: Merge biased refcounts on behalf of detached threads (#157839) (#158011) 2026-09-29 10:13:34 +03:00
bytecodes.c [3.15] gh-151818: Fix double-free in _CALL_LIST_APPEND on allocation failure (GH-151826) (#160200) 2026-10-22 06:23:06 -07:00
ceval.c [3.15] gh-159136: Avoid stop-the-world when setting function name attributes (gh-159269) (gh-159725) 2026-10-29 15:17:50 -07:00
ceval.h [3.15] gh-159136: Avoid stop-the-world when setting function name attributes (gh-159269) (gh-159725) 2026-10-29 15:17:50 -07:00
ceval_gil.c gh-144748: Make PyErr_CheckSignals raise the exception scheduled by PyThreadState_SetAsyncExc (GH-145178) 2026-03-02 11:47:32 +01:00
ceval_macros.h [3.15] gh-129752: Don't update adaptive counters when TLBC=0 in free-threading. (gh-155497) (#155647) 2026-08-26 14:52:45 +09:00
codecs.c [3.15] gh-159739: Hold the codec registry lock while unregistering (GH-160168) (#160292) 2026-10-22 15:26:02 -07:00
codegen.c [3.15] gh-143493: fix cleanup on errors in codegen_comprehension (GH-156374) (GH-156962) 2026-10-13 11:51:33 +02:00
compile.c [3.15] gh-156459: Fix cleanup on error in compiler_set_qualname (GH-156462) (GH-156574) 2026-10-10 13:58:08 +03:00
condvar.h gh-104530: Enable native Win32 condition variables by default (GH-104531) 2024-02-02 13:50:51 +00:00
config_common.h
context.c [3.15] gh-159739: Preserve ContextVar cache updates from finalizers (GH-160197) (#160330) 2026-10-22 15:22:23 -07:00
critical_section.c [3.15] gh-150902: Optimize PyCriticalSection2 to skip locking the same locks held by the current CS2 (gh-151554) 2026-06-19 09:52:07 -04:00
crossinterp.c [3.15] Fix unchecked NULL returns in several C modules (GH-160213) (#160262) 2026-10-22 21:38:32 +01:00
crossinterp_data_lookup.h gh-147960: Fix memory leak in crossinterp _tuple_shared() on alloc failure (#147961) 2026-04-01 18:34:55 +02:00
crossinterp_exceptions.h gh-132775: Clean Up Cross-Interpreter Error Handling (gh-135369) 2025-06-13 16:45:21 -06:00
dtoa.c [3.15] gh-158446: Reject float format precision near INT_MAX (GH-158474) (#158476) 2026-09-30 11:18:45 +03:00
dup2.c gh-108765: Python.h no longer includes <unistd.h> (#108783) 2023-09-02 16:50:18 +02:00
dynamic_annotations.c bpo-32241: Add the const qualifire to declarations of umodifiable strings. (#4748) 2017-12-12 13:55:04 +02:00
dynload_hpux.c gh-88402: Add new sysconfig variables on Windows (GH-110049) 2023-10-04 22:50:29 +00:00
dynload_shlib.c [3.15] gh-122931: Allow stable abi3 API extensions to include a multiarch tuple in the filename (GH-152461) (GH-154772) 2026-07-29 10:21:30 +02:00
dynload_stub.c gh-88402: Add new sysconfig variables on Windows (GH-110049) 2023-10-04 22:50:29 +00:00
dynload_win.c gh-148690: Build Windows freethreaded binaries into separate directory and include python3t.dll on GIL-enabled (GH-149218) 2026-05-04 17:45:08 +01:00
emscripten_signal.c GH-108614: Unbreak emscripten build (GH-109132) 2023-09-08 17:54:45 +01:00
emscripten_syscalls.c
emscripten_trampoline.c gh-145037: Fix Emscripten trampoline with emcc >= 4.0.19 (#145038) 2026-02-26 06:21:05 +08:00
emscripten_trampoline_inner.c gh-128627: Use __builtin_wasm_test_function_pointer_signature for Emscripten trampoline (#137470) 2025-09-17 15:33:55 +01:00
errors.c [3.15] gh-156204: Guard recursion in PyErr_GivenExceptionMatches (GH-156205) (GH-158622) 2026-10-11 07:20:28 +00:00
executor_cases.c.h [3.15] gh-151818: Fix double-free in _CALL_LIST_APPEND on allocation failure (GH-151826) (#160200) 2026-10-22 06:23:06 -07:00
fileutils.c [3.15] gh-158893: Make os.strerror() thread-safe (#159120) 2026-10-10 22:08:49 +02:00
flowgraph.c [3.15] gh-130279: Fix missing exception handlers for jumps in loops (GH-159460) (#159698) 2026-10-19 08:43:26 +00:00
frame.c gh-144446: Fix some frame object thread-safety issues (gh-144479) 2026-02-06 09:43:36 -05:00
frozen.c [3.15] gh-148750: Unfreeze encodings module to avoid import errors with zipped stdlib (GH-156183) (#156328) 2026-08-27 13:51:03 +03:00
frozenmain.c Use PyConfig_Get() in frozenmain.c (#137421) 2025-08-06 14:33:28 +02:00
future.c gh-126139: Improve error message location for future statement with unknown feature (#126140) 2024-10-29 23:57:59 +00:00
gc.c [3.15] Restore deferred backports for 3.15.1, including GH-158874 (#158882) 2026-10-11 15:42:59 +01:00
gc_free_threading.c [3.15] gh-159111: Update vendored mimalloc to v2.5.2 (gh-159112) (gh-160178) 2026-10-22 09:55:05 -07:00
gc_gil.c gh-100240: Use a consistent implementation for freelists (#121934) 2024-07-22 12:08:27 -04:00
generated_cases.c.h [3.15] gh-151818: Fix double-free in _CALL_LIST_APPEND on allocation failure (GH-151826) (#160200) 2026-10-22 06:23:06 -07:00
getargs.c gh-146615: Fix format specifiers in Python/ directory (GH-146619) 2026-03-31 10:59:17 +03:00
getcompiler.c gh-141341: Rename COMPILER macro to _Py_COMPILER on Windows (#141342) 2025-11-10 15:50:51 +01:00
getcopyright.c gh-126133: Only use start year in PSF copyright, remove end years (#126236) 2024-11-12 15:59:19 +02:00
getopt.c GH-133336: Remove reserved `-J` flag for Jython (#133444) 2025-05-05 15:09:19 +00:00
getplatform.c bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
getversion.c gh-119132: Remove "experimental" tag from the CPython free-threading. (gh-135550) 2025-06-16 23:32:52 +09:00
hamt.c [3.15] gh-155515: Use GC tracking for HAMT iterators (GH-155517) (#155697) 2026-08-17 03:58:10 +00:00
hashtable.c gh-111545: Add Py_HashPointer() function (#112096) 2023-12-06 15:09:22 +01:00
import.c [3.15] gh-159652: Fix import lock leak when the C stack is nearly exhausted (GH-159660) (GH-160779) 2026-10-27 22:17:27 +00:00
importdl.c
index_pool.c gh-91048: Refactor and optimize remote debugging module (#134652) 2025-05-25 20:19:29 +00:00
initconfig.c [3.15] gh-159739: Release replaced PyInitConfig strings (GH-159769) (#159809) 2026-10-20 00:18:08 +00:00
instruction_sequence.c GH-143493: Conform to spec for generator expressions while supporting virtual iterators (GH-143569) 2026-01-16 09:11:58 +00:00
instrumentation.c [3.15] gh-158121: Preserve instruction events when line monitoring is disabled (GH-158456) (#159733) 2026-10-19 19:47:56 +00:00
interpconfig.c [3.15] gh-159739: Handle interpreter configuration encoding errors (GH-159747) (#159843) 2026-10-20 11:12:17 -07:00
intrinsics.c gh-111489: Remove _PyTuple_FromArray() alias (#139973) 2025-10-11 22:58:14 +02:00
jit.c GH-143732: SEND specialization (GH-148963) 2026-05-05 15:19:16 +01:00
jit_publish.c GH-126910: Add GNU backtrace support for unwinding JIT frames (#149104) 2026-05-05 09:29:07 +01:00
jit_unwind.c [3.15] gh-139808: Add branch protections for aarch64 in asm_trampoline.S (GH-130864) (#149730) 2026-05-12 22:10:24 +02:00
legacy_tracing.c gh-148037: remove critical section from PyCode_Addr2Line (#148103) 2026-04-10 17:58:17 +05:30
lock.c [3.15] gh-158973: Reset the warnings lock after fork in the child (gh-158974) (gh-159614) 2026-10-19 14:54:15 -07:00
marshal.c [3.15] gh-159111: Update vendored mimalloc to v2.5.2 (gh-159112) (gh-160178) 2026-10-22 09:55:05 -07:00
modsupport.c gh-146636: Py_mod_abi mandatory for modules created from slots array (GH-146855) 2026-04-02 13:54:21 +02:00
mysnprintf.c Add a warning message about PyOS_snprintf (#95993) 2022-10-07 11:49:53 -07:00
mystrtoul.c gh-108765: Python.h no longer includes <ctype.h> (#108831) 2023-09-03 18:54:27 +02:00
object_stack.c gh-100240: Use a consistent implementation for freelists (#121934) 2024-07-22 12:08:27 -04:00
opcode_targets.h GH-143732: SEND specialization (GH-148963) 2026-05-05 15:19:16 +01:00
optimizer.c [3.15] Backport GH-148874: Make sure that mngr.__exit__() is always called in a with statement (GH-150911) (GH-154830) 2026-08-03 16:23:34 +01:00
optimizer_analysis.c [3.15] gh-145235: Make dict watcher API thread-safe for free-threaded builds (gh-145233) (#149690) 2026-05-11 14:23:39 -04:00
optimizer_bytecodes.c [3.15] gh-157468: Validate correct builtins used under JIT (GH-157766) (GH-159048) 2026-10-12 16:31:15 +02:00
optimizer_cases.c.h [3.15] gh-157468: Validate correct builtins used under JIT (GH-157766) (GH-159048) 2026-10-12 16:31:15 +02:00
optimizer_symbols.c [3.15] gh-157468: Validate correct builtins used under JIT (GH-157766) (GH-159048) 2026-10-12 16:31:15 +02:00
parking_lot.c gh-148820: Fix _PyRawMutex use-after-free on spurious semaphore wakeup (gh-148852) 2026-04-22 14:31:19 -04:00
pathconfig.c gh-133644: Remove deprecated Python initialization getter functions (#133661) 2025-05-09 11:39:23 +00:00
perf_jit_trampoline.c [3.15] gh-156114: Fix crash in perf trampoline with unencodable code names (GH-156300) (#157773) 2026-09-18 21:37:15 +00:00
perf_trampoline.c [3.15] gh-156114: Fix crash in perf trampoline with unencodable code names (GH-156300) (#157773) 2026-09-18 21:37:15 +00:00
preconfig.c gh-146302: make Py_IsInitialized() thread-safe and reflect true init completion (GH-146303) 2026-04-11 21:54:23 +00:00
pyarena.c Chore: Fix typo in pyarena.c (#126527) 2024-11-07 16:37:41 +01:00
pyctype.c Include files missed in r72044. 2009-04-27 20:54:42 +00:00
pyfpe.c bpo-46315: Add ifdef HAVE_ feature checks for WASI compatibility (GH-30507) 2022-01-13 09:46:04 +01:00
pyhash.c
pylifecycle.c [3.15] Fix ignored error returns in sys initialization, _ctypes and _interpchannels (GH-160614) (#160711) 2026-10-26 19:49:41 +00:00
pymath.c bpo-45440: Remove pymath.c fallbacks (GH-28977) 2021-10-15 19:45:34 +02:00
pystate.c [3.15] gh-159111: Update vendored mimalloc to v2.5.2 (gh-159112) (gh-160178) 2026-10-22 09:55:05 -07:00
pystats.c gh-146073: Add fitness/exit quality mechanism for JIT trace frontend (GH-148089) 2026-04-24 10:37:01 +01:00
pystrcmp.c gh-108767: Replace ctype.h functions with pyctype.h functions (#108772) 2023-09-01 18:36:53 +02:00
pystrhex.c [3.15] gh-149685: Use the _Py prefix for private C macros (GH-149686) (GH-149790) 2026-05-13 23:29:08 +02:00
pystrtod.c [3.15] gh-158446: Reject float format precision near INT_MAX (GH-158474) (#158476) 2026-09-30 11:18:45 +03:00
Python-ast.c [3.15] gh-156909: Fix AST.__repr__ call getting the _fields attribute (GH-157490) (GH-157596) 2026-10-12 14:08:25 +02:00
Python-tokenize.c gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770) 2026-03-24 17:47:55 +00:00
pythonrun.c [3.15] gh-152132: Test Py_CompileString() in test_capi.test_run (GH-153470) (#153472) 2026-07-10 02:07:38 +00:00
pytime.c [3.15] gh-152849: Fix OverflowError message for out-of-range timestamps in the time module (GH-152850) (#153209) 2026-07-06 15:25:47 +00:00
qsbr.c
README Issue #18093: Factor out the programs that embed the runtime 2014-07-25 21:52:14 +10:00
record_functions.c.h GH-143732: SEND specialization (GH-148963) 2026-05-05 15:19:16 +01:00
remote_debug.h [3.15] Restore deferred backports for 3.15.1, including GH-158874 (#158882) 2026-10-11 15:42:59 +01:00
remote_debugging.c
slots.c gh-149044: Implement PEP 820 – PySlot: Unified slot system for the C API (GH-149055) 2026-05-05 09:18:04 +02:00
slots.toml gh-149044: Implement PEP 820 – PySlot: Unified slot system for the C API (GH-149055) 2026-05-05 09:18:04 +02:00
slots_generated.c gh-149044: Implement PEP 820 – PySlot: Unified slot system for the C API (GH-149055) 2026-05-05 09:18:04 +02:00
specialize.c [3.15] gh-152075: Avoid lock contention in _Py_Specialize_LoadGlobal under free threading (gh-153720) (#158905) 2026-10-10 16:03:02 +05:30
stackrefs.c gh-131527: Stackref debug borrow checker (#140599) 2025-11-05 11:12:56 -08:00
stdlib_module_names.h
structmember.c gh-146270: Fix PyMember_SetOne(..., NULL) not being atomic (gh-148800) 2026-05-06 09:50:24 -04:00
suggestions.c GH-131238: Core header refactor (GH-131250) 2025-03-17 09:19:04 +00:00
symtable.c [3.15] gh-160299: Preserve references from inlined comprehensions (GH-156819) (#160413) 2026-10-23 10:41:48 -07:00
sysmodule.c [3.15] gh-157247: Block perf trampoline activation when the main interpreter's JIT is enabled (GH-157258) (#157324) 2026-09-23 01:11:38 +01:00
thread.c gh-134745: Use "pymutex" for sys.thread_info on Windows (#141140) 2025-11-06 16:10:39 +01:00
thread_nt.h [3.15] gh-134745: Remove dead code in thread_nt.h left by gh-134747 (GH-154338) (#154655) 2026-07-24 23:01:47 +00:00
thread_pthread.h [3.15] gh-157415: Fix data race in pthread wrapper (#157430) (#159277) 2026-10-12 23:32:24 +00:00
thread_pthread_stubs.h
tier2_engine.md
traceback.c [3.15] gh-113318: Fix @getter and @setter in Argument Clinic (GH-155778) (GH-156010) 2026-10-09 20:54:35 +03:00
tracemalloc.c [3.15] gh-155725: Remove PyGILState_Ensure usage from tracemalloc (GH-156409) (#156628) 2026-08-31 09:53:56 +03:00
uniqueid.c gh-128923: Use zero to indicate unassigned unique id (#128925) 2025-01-17 16:42:27 +01:00
vm-state.md gh-133079: Remove Py_C_RECURSION_LIMIT & PyThreadState.c_recursion_remaining (GH-133080) 2025-04-29 12:56:20 +02:00

Miscellaneous source files for the main Python shared library