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
allocation.rst Docs: remove redundant "adverb-adjective" hyphens from compound modifiers (GH-94551) 2022-07-05 11:16:10 +02:00
apiabiversion.rst
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
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
code.rst GH-91054: Add code object watchers API (GH-99859) 2022-12-02 17:28:27 +00:00
codec.rst
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
conversion.rst Add a warning message about PyOS_snprintf (#95993) 2022-10-07 11:49:53 -07:00
coro.rst
datetime.rst gh-90359: Unify documentation style for datetime.rst (gh-94836) 2022-07-14 09:40:10 +09:00
descriptor.rst
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
gen.rst
import.rst gh-65961: Do not rely solely on `__cached__` (GH-97990) 2022-10-06 15:40:22 -07:00
index.rst
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
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
number.rst Document Py_ssize_t. (GH-92512) 2022-05-13 14:10:16 +02:00
objbuffer.rst
object.rst gh-93738: Documentation C syntax (:c:type:`PyTypeObject*` -> :c:expr:`PyTypeObject*`) (#97778) 2022-10-04 17:56:20 -07:00
objimpl.rst
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
stable.rst
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
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