diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-27 13:44:33 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-27 13:44:33 (GMT) |
commit | 726fc139a5f40d81a0013c856be1283da08de4a0 (patch) | |
tree | 7a7fe3b19e13842df5b5d45a8567fbfb5e7bbd75 /Objects | |
parent | bdb908ea5466bfa09869fd2e1e7f3b17fe0fb2ea (diff) | |
parent | 191321d11bc7e064e1a07830a43fa600de310e1b (diff) | |
download | cpython-726fc139a5f40d81a0013c856be1283da08de4a0.zip cpython-726fc139a5f40d81a0013c856be1283da08de4a0.tar.gz cpython-726fc139a5f40d81a0013c856be1283da08de4a0.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')
-rw-r--r-- | Objects/exceptions.c | 19 | ||||
-rw-r--r-- | Objects/unicodeobject.c | 2 |
2 files changed, 11 insertions, 10 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; \ } \ diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index bda2469..fb79bd9 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -14443,8 +14443,8 @@ unicode_format_arg_parse(struct unicode_formatter_t *ctx, if (key == NULL) return -1; if (ctx->args_owned) { - Py_DECREF(ctx->args); ctx->args_owned = 0; + Py_DECREF(ctx->args); } ctx->args = PyObject_GetItem(ctx->dict, key); Py_DECREF(key); |