summaryrefslogtreecommitdiffstats
path: root/Objects/genobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-01-05 19:27:54 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-01-05 19:27:54 (GMT)
commit576f132b986b5ee60e4b84d34a519a5edcd8c03e (patch)
treef048292ddc0b5c3d6a5afc50dc2cd4b28372c655 /Objects/genobject.c
parentdcf76c9d0ab11f77eaa856ff0583c5c636ddb47d (diff)
downloadcpython-576f132b986b5ee60e4b84d34a519a5edcd8c03e.zip
cpython-576f132b986b5ee60e4b84d34a519a5edcd8c03e.tar.gz
cpython-576f132b986b5ee60e4b84d34a519a5edcd8c03e.tar.bz2
Issue #20440: Cleaning up the code by using Py_SETREF.
Diffstat (limited to 'Objects/genobject.c')
-rw-r--r--Objects/genobject.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c
index 00ebbf1..81a80b7 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -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;
}