diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-01-05 21:27:54 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-01-05 21:27:54 +0200 |
commit | 93c98b688bef3bf08c027315a744869b590ceef3 (patch) | |
tree | 40957d06fc05cda36c06cca475e8bef11999ed78 /Objects/genobject.c | |
parent | c8a68313d9003cacd48415cca4beb12b7bf386ba (diff) | |
download | cpython-93c98b688bef3bf08c027315a744869b590ceef3.tar.gz |
Issue #20440: Cleaning up the code by using Py_SETREF.
Diffstat (limited to 'Objects/genobject.c')
-rw-r--r-- | Objects/genobject.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c index 00ebbf1cf8..81a80b7ea7 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; } |