summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-12-27 13:41:34 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-12-27 13:41:34 (GMT)
commit191321d11bc7e064e1a07830a43fa600de310e1b (patch)
tree083b269838ac1e7dbea54ead1a4b79e99dbf4891 /Objects
parent4a1e70fc31d224786a32f950edaf73c8ea9c194d (diff)
downloadcpython-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')
-rw-r--r--Objects/exceptions.c19
-rw-r--r--Objects/unicodeobject.c2
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 c5b35e1..c957929 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -14191,8 +14191,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);