GH-125323: Convert DECREF_INPUTS_AND_REUSE_FLOAT into a function that takes PyStackRefs. (GH-125439)

This commit is contained in:
Mark Shannon 2024-10-14 14:18:57 +01:00 committed by GitHub
parent 67f6e08147
commit 06ca33020e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 69 additions and 44 deletions

View file

@ -327,26 +327,6 @@ GETITEM(PyObject *v, Py_ssize_t i) {
" in enclosing scope"
#define NAME_ERROR_MSG "name '%.200s' is not defined"
#define DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dval, result) \
do { \
if (Py_REFCNT(left) == 1) { \
((PyFloatObject *)left)->ob_fval = (dval); \
_Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc);\
result = (left); \
} \
else if (Py_REFCNT(right) == 1) {\
((PyFloatObject *)right)->ob_fval = (dval); \
_Py_DECREF_NO_DEALLOC(left); \
result = (right); \
}\
else { \
result = PyFloat_FromDouble(dval); \
if ((result) == NULL) GOTO_ERROR(error); \
_Py_DECREF_NO_DEALLOC(left); \
_Py_DECREF_NO_DEALLOC(right); \
} \
} while (0)
// If a trace function sets a new f_lineno and
// *then* raises, we use the destination when searching
// for an exception handler, displaying the traceback, and so on