From 191321d11bc7e064e1a07830a43fa600de310e1b Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 27 Dec 2015 15:41:34 +0200 Subject: Issue #20440: More use of Py_SETREF. This patch is manually crafted and contains changes that couldn't be handled automatically. --- Objects/exceptions.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'Objects/exceptions.c') diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 351304fe43..85f9472d2a 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; \ } \ -- cgit v1.2.1