diff options
Diffstat (limited to 'Objects/genobject.c')
-rw-r--r-- | Objects/genobject.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c index f74d044..c94a6ed 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -187,7 +187,7 @@ gen_send_ex(PyGenObject *gen, PyObject *arg, int exc, int closing) /* Pop the exception before issuing a warning. */ PyErr_Fetch(&exc, &val, &tb); - if (PyErr_WarnFormat(PyExc_PendingDeprecationWarning, 1, + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, "generator '%.50S' raised StopIteration", gen->gi_qualname)) { /* Warning was converted to an error. */ @@ -519,8 +519,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)) { @@ -528,10 +526,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_XSETREF(op->gi_name, value); return 0; } @@ -545,8 +541,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)) { @@ -554,10 +548,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_XSETREF(op->gi_qualname, value); return 0; } |