mirror of
https://github.com/python/cpython.git
synced 2025-11-25 12:44:13 +00:00
gh-99300: Use Py_NewRef() in Modules/ directory (#99440)
Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in test C files of the Modules/ directory.
This commit is contained in:
parent
0bedc28d14
commit
bbba3f3f43
6 changed files with 41 additions and 82 deletions
|
|
@ -57,8 +57,7 @@ Example_demo(ExampleObject *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "|O:demo", &o))
|
||||
return NULL;
|
||||
if (o != NULL && PyUnicode_Check(o)) {
|
||||
Py_INCREF(o);
|
||||
return o;
|
||||
return Py_NewRef(o);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
|
@ -77,8 +76,7 @@ Example_getattro(ExampleObject *self, PyObject *name)
|
|||
if (self->x_attr != NULL) {
|
||||
PyObject *v = PyDict_GetItemWithError(self->x_attr, name);
|
||||
if (v != NULL) {
|
||||
Py_INCREF(v);
|
||||
return v;
|
||||
return Py_NewRef(v);
|
||||
}
|
||||
else if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
|
|
@ -151,8 +149,7 @@ _testmultiphase_StateAccessType_get_defining_module_impl(StateAccessTypeObject *
|
|||
return NULL;
|
||||
}
|
||||
assert(PyType_GetModuleByDef(Py_TYPE(self), &def_meth_state_access) == retval);
|
||||
Py_INCREF(retval);
|
||||
return retval;
|
||||
return Py_NewRef(retval);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue