cpython/Doc/c-api
Victor Stinner b11a384dc7
gh-98724: Fix Py_CLEAR() macro side effects (#99100) (#100070)
The Py_CLEAR(), Py_SETREF() and Py_XSETREF() macros now only evaluate
their arguments once. If an argument has side effects, these side
effects are no longer duplicated.

Use temporary variables to avoid duplicating side effects of macro
arguments. If available, use _Py_TYPEOF() to avoid type punning.
Otherwise, use memcpy() for the assignment to prevent a
miscompilation with strict aliasing caused by type punning.

Add _Py_TYPEOF() macro: __typeof__() on GCC and clang.

Add test_py_clear() and test_py_setref() unit tests to _testcapi.
2022-12-07 15:22:38 +01:00
..
abstract.rst bpo-41103: Resurrect the old buffer protocol. (GH-27437) 2021-07-29 12:46:47 +02:00
allocation.rst Docs: remove redundant "adverb-adjective" hyphens from compound modifiers (GH-94551) 2022-07-05 11:16:10 +02:00
apiabiversion.rst Doc: some rst linting. (GH-30149) 2021-12-17 13:55:03 +01:00
arg.rst gh-93738: Documentation C syntax (:c:type:<C type> -> :c:expr:<C type>) (#97768) 2022-10-05 11:01:14 -07:00
bool.rst bpo-42528: Improve the docs of most Py*_Check{,Exact} API calls (GH-23602) 2021-01-06 12:38:26 +01:00
buffer.rst Fix types in buffer/memoryview docs (#98118) 2022-10-09 17:55:53 -07:00
bytearray.rst gh-89653: PEP 670: Convert PyBytes macros to functions (#91990) 2022-05-03 20:14:58 +02:00
bytes.rst gh-93202: Always use %zd printf formatter (#93201) 2022-05-25 14:21:36 +02:00
call.rst gh-98586: Add What's New entry and update docs (#99056) 2022-11-06 23:54:55 +01:00
capsule.rst gh-93738: Documentation C syntax (:c:type:<C type> -> :c:expr:<C type>) (#97768) 2022-10-05 11:01:14 -07:00
cell.rst bpo-42528: Improve the docs of most Py*_Check{,Exact} API calls (GH-23602) 2021-01-06 12:38:26 +01:00
code.rst GH-91054: Add code object watchers API (GH-99859) 2022-12-02 17:28:27 +00:00
codec.rst bpo-41842: Add codecs.unregister() function (GH-22360) 2020-09-28 23:41:11 +02:00
complex.rst gh-93738: Documentation C syntax (:c:type:<C type> -> :c:expr:<C type>) (#97768) 2022-10-05 11:01:14 -07:00
concrete.rst bpo-46836: Add Doc/c-api/frame.rst (GH-32051) 2022-03-23 13:19:13 +01:00
contextvars.rst bpo-43959: clarify the documentation of the PyContextVar C-API (GH-25671) 2021-04-28 07:03:19 -07:00
conversion.rst Add a warning message about PyOS_snprintf (#95993) 2022-10-07 11:49:53 -07:00
coro.rst bpo-42528: Improve the docs of most Py*_Check{,Exact} API calls (GH-23602) 2021-01-06 12:38:26 +01:00
datetime.rst gh-90359: Unify documentation style for datetime.rst (gh-94836) 2022-07-14 09:40:10 +09:00
descriptor.rst bpo-40170: Convert PyDescr_IsData() to static inline function (GH-24535) 2021-02-16 08:50:00 +01:00
dict.rst gh-91052: Add PyDict_Unwatch for unwatching a dictionary (#98055) 2022-10-07 17:37:46 -07:00
exceptions.rst gh-93738: Documentation C syntax (Function glob patterns -> literal markup) (#97774) 2022-10-05 08:22:28 -07:00
file.rst gh-93738: Documentation C syntax (:c:type:<C type> -> :c:expr:<C type>) (#97768) 2022-10-05 11:01:14 -07:00
float.rst gh-93738: Documentation C syntax (:c:type:<C type> -> :c:expr:<C type>) (#97768) 2022-10-05 11:01:14 -07:00
frame.rst gh-93937: Document PyFrame_Check and PyFrame_Type (GH-99695) 2022-11-22 16:41:57 +01:00
function.rst gh-91053: Add an optional callback that is invoked whenever a function is modified (#98175) 2022-11-22 13:06:44 +01:00
gcsupport.rst bpo-28737: Document when tp_dealloc should call PyObject_GC_UnTrack() (GH-29246) 2021-10-27 21:15:13 +02:00
gen.rst bpo-42528: Improve the docs of most Py*_Check{,Exact} API calls (GH-23602) 2021-01-06 12:38:26 +01:00
import.rst gh-65961: Do not rely solely on `__cached__` (GH-97990) 2022-10-06 15:40:22 -07:00
index.rst bpo-36763: Implement the PEP 587 (GH-13592) 2019-05-27 16:39:22 +02:00
init.rst gh-99377: Revert audit events for thread state creation and free, because the GIL is not properly held at these times (GH-99543) 2022-11-17 00:24:16 +00:00
init_config.rst Doc: Replace question mark with fullstop (#99558) 2022-11-18 11:24:23 -08:00
intro.rst gh-93738: Documentation C syntax (:c:type:<C type> -> :c:expr:<C type>) (#97768) 2022-10-05 11:01:14 -07:00
iter.rst More minor fixes to C API docs (GH-31525) 2022-04-02 12:31:05 -07:00
iterator.rst bpo-42528: Improve the docs of most Py*_Check{,Exact} API calls (GH-23602) 2021-01-06 12:38:26 +01:00
list.rst gh-89653: PEP 670: Amend docs (GH-91813) 2022-04-22 14:59:18 +02:00
long.rst gh-93738: Documentation C syntax (:c:type:<C type> -> :c:expr:<C type>) (#97768) 2022-10-05 11:01:14 -07:00
mapping.rst More minor fixes to C API docs (GH-31525) 2022-04-02 12:31:05 -07:00
marshal.rst gh-93738: Documentation C syntax (:c:type:<C type> -> :c:expr:<C type>) (#97768) 2022-10-05 11:01:14 -07:00
memory.rst gh-96997: Clarify the contract of PyMem_SetAllocator() (#98977) 2022-11-02 21:49:12 +00:00
memoryview.rst Fix types in buffer/memoryview docs (#98118) 2022-10-09 17:55:53 -07:00
method.rst More minor fixes to C API docs (GH-31525) 2022-04-02 12:31:05 -07:00
module.rst gh-93738: Documentation C syntax (Function glob patterns -> literal markup) (#97774) 2022-10-05 08:22:28 -07:00
none.rst Doc: Replace the deprecated highlightlang directive by highlight. (#13377) 2019-05-17 15:25:34 +05:30
number.rst Document Py_ssize_t. (GH-92512) 2022-05-13 14:10:16 +02:00
objbuffer.rst bpo-41103: Resurrect the old buffer protocol. (GH-27437) 2021-07-29 12:46:47 +02:00
object.rst gh-93738: Documentation C syntax (:c:type:`PyTypeObject*` -> :c:expr:`PyTypeObject*`) (#97778) 2022-10-04 17:56:20 -07:00
objimpl.rst Doc: Replace the deprecated highlightlang directive by highlight. (#13377) 2019-05-17 15:25:34 +05:30
refcounting.rst gh-98724: Fix Py_CLEAR() macro side effects (#99100) (#100070) 2022-12-07 15:22:38 +01:00
reflection.rst bpo-46836: Add Doc/c-api/frame.rst (GH-32051) 2022-03-23 13:19:13 +01:00
sequence.rst More minor fixes to C API docs (GH-31525) 2022-04-02 12:31:05 -07:00
set.rst More minor fixes to C API docs (GH-31525) 2022-04-02 12:31:05 -07:00
slice.rst bpo-42528: Improve the docs of most Py*_Check{,Exact} API calls (GH-23602) 2021-01-06 12:38:26 +01:00
stable.rst Reword paragraph on specific value for Py_LIMITED_API (GH-26101) 2021-05-13 22:22:44 -07:00
structures.rst gh-47146: Soft-deprecate structmember.h, expose its contents via Python.h (GH-99014) 2022-11-22 08:25:43 +01:00
sys.rst gh-93738: Documentation C syntax (:c:type:<C type> -> :c:expr:<C type>) (#97768) 2022-10-05 11:01:14 -07:00
tuple.rst no-issue: typo fix in c-api/tuple.rst (gh-98560) 2022-10-23 19:46:56 +09:00
type.rst gh-91051: allow setting a callback hook on PyType_Modified (GH-97875) 2022-10-21 14:41:51 +01:00
typehints.rst gh-93738: Documentation C syntax (:c:type:`PyTypeObject*` -> :c:expr:`PyTypeObject*`) (#97778) 2022-10-04 17:56:20 -07:00
typeobj.rst gh-99249: Clarify "read-only" slots tp_bases & tp_mro (GH-99342) 2022-11-28 09:22:08 +01:00
unicode.rst gh-93738: Documentation C syntax (:c:type:<C type> -> :c:expr:<C type>) (#97768) 2022-10-05 11:01:14 -07:00
utilities.rst Doc: Replace the deprecated highlightlang directive by highlight. (#13377) 2019-05-17 15:25:34 +05:30
veryhigh.rst gh-93738: Documentation C syntax (:c:type:`FILE` -> :c:expr:`FILE`) (#97769) 2022-10-04 16:27:29 -07:00
weakref.rst Docs: remove redundant "adverb-adjective" hyphens from compound modifiers (GH-94551) 2022-07-05 11:16:10 +02:00