diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-27 13:41:34 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-27 13:41:34 (GMT) |
commit | 191321d11bc7e064e1a07830a43fa600de310e1b (patch) | |
tree | 083b269838ac1e7dbea54ead1a4b79e99dbf4891 /Objects/exceptions.c | |
parent | 4a1e70fc31d224786a32f950edaf73c8ea9c194d (diff) | |
download | cpython-191321d11bc7e064e1a07830a43fa600de310e1b.zip cpython-191321d11bc7e064e1a07830a43fa600de310e1b.tar.gz cpython-191321d11bc7e064e1a07830a43fa600de310e1b.tar.bz2 |
Issue #20440: More use of Py_SETREF.
This patch is manually crafted and contains changes that couldn't be handled
automatically.
Diffstat (limited to 'Objects/exceptions.c')
-rw-r--r-- | Objects/exceptions.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 351304f..85f9472 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -561,12 +561,14 @@ SystemExit_init(PySystemExitObject *self, PyObject *args, PyObject *kwds) if (size == 0) return 0; - Py_CLEAR(self->code); - if (size == 1) - self->code = PyTuple_GET_ITEM(args, 0); - else /* size > 1 */ - self->code = args; - Py_INCREF(self->code); + if (size == 1) { + Py_INCREF(PyTuple_GET_ITEM(args, 0)); + Py_SETREF(self->code, PyTuple_GET_ITEM(args, 0)); + } + else { /* size > 1 */ + Py_INCREF(args); + Py_SETREF(self->code, args); + } return 0; } @@ -625,9 +627,8 @@ ImportError_init(PyImportErrorObject *self, PyObject *args, PyObject *kwds) #define GET_KWD(kwd) { \ kwd = PyDict_GetItemString(kwds, #kwd); \ if (kwd) { \ - Py_CLEAR(self->kwd); \ - self->kwd = kwd; \ - Py_INCREF(self->kwd);\ + Py_INCREF(kwd); \ + Py_SETREF(self->kwd, kwd); \ if (PyDict_DelItemString(kwds, #kwd)) \ return -1; \ } \ |