gh-89653: PEP 670: Convert PyCell macros to functions (#92653)

Convert the following macros to static inline functions:

* PyCell_GET()
* PyCell_SET()

Limited C API version 3.12 no longer casts arguments.

Fix also usage of PyCell_SET(): only delete the old value after
setting the new value.
This commit is contained in:
Victor Stinner 2022-05-11 23:24:48 +02:00 committed by GitHub
parent da5727a120
commit 897f14d38d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 11 deletions

View file

@ -1086,9 +1086,9 @@ _PyFrame_LocalsToFast(_PyInterpreterFrame *frame, int clear)
if (cell != NULL) {
oldvalue = PyCell_GET(cell);
if (value != oldvalue) {
Py_XDECREF(oldvalue);
Py_XINCREF(value);
PyCell_SET(cell, value);
Py_XDECREF(oldvalue);
}
}
else if (value != oldvalue) {