diff options
Diffstat (limited to 'Python/pystate.c')
-rw-r--r-- | Python/pystate.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/Python/pystate.c b/Python/pystate.c index df0f4e2..b5fd8c2 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -944,9 +944,8 @@ _PyState_AddModule(PyThreadState *tstate, PyObject* module, PyModuleDef* def) } } - Py_INCREF(module); return PyList_SetItem(interp->modules_by_index, - def->m_base.m_index, module); + def->m_base.m_index, Py_NewRef(module)); } int @@ -994,8 +993,7 @@ PyState_RemoveModule(PyModuleDef* def) Py_FatalError("Module index out of bounds."); } - Py_INCREF(Py_None); - return PyList_SetItem(interp->modules_by_index, index, Py_None); + return PyList_SetItem(interp->modules_by_index, index, Py_NewRef(Py_None)); } // Used by finalize_modules() @@ -1299,8 +1297,7 @@ PyThreadState_GetFrame(PyThreadState *tstate) if (frame == NULL) { PyErr_Clear(); } - Py_XINCREF(frame); - return frame; + return (PyFrameObject*)Py_XNewRef(frame); } @@ -1346,8 +1343,7 @@ PyThreadState_SetAsyncExc(unsigned long id, PyObject *exc) * the decref. */ PyObject *old_exc = tstate->async_exc; - Py_XINCREF(exc); - tstate->async_exc = exc; + tstate->async_exc = Py_XNewRef(exc); HEAD_UNLOCK(runtime); Py_XDECREF(old_exc); @@ -2027,8 +2023,7 @@ _bytes_shared(PyObject *obj, _PyCrossInterpreterData *data) return -1; } data->data = (void *)shared; - Py_INCREF(obj); - data->obj = obj; // Will be "released" (decref'ed) when data released. + data->obj = Py_NewRef(obj); // Will be "released" (decref'ed) when data released. data->new_object = _new_bytes_object; data->free = PyMem_Free; return 0; @@ -2055,8 +2050,7 @@ _str_shared(PyObject *obj, _PyCrossInterpreterData *data) shared->buffer = PyUnicode_DATA(obj); shared->len = PyUnicode_GET_LENGTH(obj); data->data = (void *)shared; - Py_INCREF(obj); - data->obj = obj; // Will be "released" (decref'ed) when data released. + data->obj = Py_NewRef(obj); // Will be "released" (decref'ed) when data released. data->new_object = _new_str_object; data->free = PyMem_Free; return 0; @@ -2093,8 +2087,7 @@ static PyObject * _new_none_object(_PyCrossInterpreterData *data) { // XXX Singleton refcounts are problematic across interpreters... - Py_INCREF(Py_None); - return Py_None; + return Py_NewRef(Py_None); } static int |