mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
Issue #20440: Cleaning up the code by using Py_SETREF.
This commit is contained in:
parent
dcf76c9d0a
commit
576f132b98
14 changed files with 39 additions and 120 deletions
|
@ -510,8 +510,6 @@ gen_get_name(PyGenObject *op)
|
|||
static int
|
||||
gen_set_name(PyGenObject *op, PyObject *value)
|
||||
{
|
||||
PyObject *tmp;
|
||||
|
||||
/* Not legal to del gen.gi_name or to set it to anything
|
||||
* other than a string object. */
|
||||
if (value == NULL || !PyUnicode_Check(value)) {
|
||||
|
@ -519,10 +517,8 @@ gen_set_name(PyGenObject *op, PyObject *value)
|
|||
"__name__ must be set to a string object");
|
||||
return -1;
|
||||
}
|
||||
tmp = op->gi_name;
|
||||
Py_INCREF(value);
|
||||
op->gi_name = value;
|
||||
Py_DECREF(tmp);
|
||||
Py_SETREF(op->gi_name, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -536,8 +532,6 @@ gen_get_qualname(PyGenObject *op)
|
|||
static int
|
||||
gen_set_qualname(PyGenObject *op, PyObject *value)
|
||||
{
|
||||
PyObject *tmp;
|
||||
|
||||
/* Not legal to del gen.__qualname__ or to set it to anything
|
||||
* other than a string object. */
|
||||
if (value == NULL || !PyUnicode_Check(value)) {
|
||||
|
@ -545,10 +539,8 @@ gen_set_qualname(PyGenObject *op, PyObject *value)
|
|||
"__qualname__ must be set to a string object");
|
||||
return -1;
|
||||
}
|
||||
tmp = op->gi_qualname;
|
||||
Py_INCREF(value);
|
||||
op->gi_qualname = value;
|
||||
Py_DECREF(tmp);
|
||||
Py_SETREF(op->gi_qualname, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue