cpython/Lib/test/test_capi
Neil Schemenauer be5386f03f
[3.14] gh-159136: Avoid stop-the-world when setting function name attributes (gh-159269) (gh-159726)
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-30 11:03:31 -07:00
..
__init__.py
__main__.py
check_config.py
test_abstract.py
test_build.py [3.14] gh-158445: Add C API tests on build information functions (#159515) (#159525) 2026-10-16 12:03:56 +00:00
test_bytearray.py
test_bytes.py [3.14] gh-158585: Backport test_capi.test_bytes from 3.15 (#159594) 2026-10-16 23:14:31 +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.14] gh-159136: Avoid stop-the-world when setting function name attributes (gh-159269) (gh-159726) 2026-10-30 11:03:31 -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_number.py
test_object.py [3.14] gh-159431: Handle immortal objects in _PyObject_XDecRefDelayed() (GH-159433) (#160228) 2026-10-22 09:31:58 +00:00
test_opt.py
test_pyatomic.py
test_run.py
test_set.py
test_slice.py [3.14] gh-158102: Add tests for the slice C API (GH-158120) (GH-158292) 2026-09-29 15:39:19 +03:00
test_structmembers.py
test_sys.py
test_time.py
test_tuple.py [3.14] gh-159739: Fix crash in _PyTuple_Resize() with an invalid size (GH-159804) (#159977) 2026-10-21 00:24:54 +00:00
test_type.py [3.14] gh-155503: Add more PyType C API tests (#155505) (#159085) (#159089) 2026-10-09 22:11:41 +00:00
test_unicode.py [3.14] gh-158585: Fix _PyBytes_Resize() if hash value is already computed (#159585) 2026-10-16 22:09:04 +00:00
test_watchers.py
test_weakref.py