cpython/Lib/test/test_capi
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
..
__init__.py
__main__.py
check_config.py
test_abstract.py
test_build.py [3.15] gh-158445: Add C API tests on build information functions (#159515) 2026-10-16 11:15:23 +00:00
test_bytearray.py
test_bytes.py [3.15] gh-158585: Backport test_capi.test_bytes from main (#159588) 2026-10-16 22:33:06 +00:00
test_capsule.py
test_codecs.py
test_complex.py
test_config.py
test_dict.py
test_emscripten.py
test_eval.py
test_eval_code_ex.py
test_exceptions.py
test_file.py
test_float.py
test_frame.py
test_function.py [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
test_getargs.py
test_hash.py
test_immortal.py
test_import.py
test_list.py
test_long.py
test_mem.py
test_misc.py
test_modsupport.py
test_module.py
test_number.py
test_object.py [3.15] gh-159431: Handle immortal objects in _PyObject_XDecRefDelayed() (GH-159433) (#160229) 2026-10-22 09:34:39 +00:00
test_opt.py [3.15] gh-155823: Fix stale stack on _SEND_VIRTUAL_TIER_TWO exhausted exit (GH-155844) (GH-158559) 2026-10-13 11:20:24 +02:00
test_pyatomic.py
test_run.py
test_set.py
test_slice.py
test_slots.py
test_structmembers.py
test_sys.py
test_time.py
test_tuple.py [3.15] gh-159739: Fix crash in _PyTuple_Resize() with an invalid size (GH-159804) (#159976) 2026-10-21 00:15:53 +00:00
test_type.py
test_unicode.py [3.15] gh-158451: Add _PyUnicodeWriter_WriteLatin1String() test (#158464) (#159551) 2026-10-16 20:28:34 +02:00
test_watchers.py
test_weakref.py