diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-24 08:35:35 (GMT) |
|---|---|---|
| committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-24 08:35:35 (GMT) |
| commit | 5951f2300f43d75d344d542e171daed47a0382a6 (patch) | |
| tree | 2e173dda0c0d4c4bf887e8a6a309430d0d9cd5be /Objects/funcobject.c | |
| parent | 6ed42ea08b3a961944e94f1dd941ffabc7657065 (diff) | |
| download | cpython-5951f2300f43d75d344d542e171daed47a0382a6.zip cpython-5951f2300f43d75d344d542e171daed47a0382a6.tar.gz cpython-5951f2300f43d75d344d542e171daed47a0382a6.tar.bz2 | |
Issue #20440: Massive replacing unsafe attribute setting code with special
macro Py_SETREF.
Diffstat (limited to 'Objects/funcobject.c')
| -rw-r--r-- | Objects/funcobject.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 51b6c9d..da54069 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -116,8 +116,7 @@ PyFunction_SetDefaults(PyObject *op, PyObject *defaults) PyErr_SetString(PyExc_SystemError, "non-tuple default args"); return -1; } - Py_XDECREF(((PyFunctionObject *) op) -> func_defaults); - ((PyFunctionObject *) op) -> func_defaults = defaults; + Py_SETREF(((PyFunctionObject *)op)->func_defaults, defaults); return 0; } @@ -149,8 +148,7 @@ PyFunction_SetClosure(PyObject *op, PyObject *closure) closure->ob_type->tp_name); return -1; } - Py_XDECREF(((PyFunctionObject *) op) -> func_closure); - ((PyFunctionObject *) op) -> func_closure = closure; + Py_SETREF(((PyFunctionObject *)op)->func_closure, closure); return 0; } @@ -430,8 +428,7 @@ func_new(PyTypeObject* type, PyObject* args, PyObject* kw) if (name != Py_None) { Py_INCREF(name); - Py_DECREF(newfunc->func_name); - newfunc->func_name = name; + Py_SETREF(newfunc->func_name, name); } if (defaults != Py_None) { Py_INCREF(defaults); |
