summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-01-05 19:27:54 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-01-05 19:27:54 (GMT)
commit576f132b986b5ee60e4b84d34a519a5edcd8c03e (patch)
treef048292ddc0b5c3d6a5afc50dc2cd4b28372c655 /Python
parentdcf76c9d0ab11f77eaa856ff0583c5c636ddb47d (diff)
downloadcpython-576f132b986b5ee60e4b84d34a519a5edcd8c03e.zip
cpython-576f132b986b5ee60e4b84d34a519a5edcd8c03e.tar.gz
cpython-576f132b986b5ee60e4b84d34a519a5edcd8c03e.tar.bz2
Issue #20440: Cleaning up the code by using Py_SETREF.
Diffstat (limited to 'Python')
-rw-r--r--Python/import.c10
-rw-r--r--Python/peephole.c4
-rw-r--r--Python/sysmodule.c5
3 files changed, 5 insertions, 14 deletions
diff --git a/Python/import.c b/Python/import.c
index 8d7bfe9..325b936 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -879,10 +879,8 @@ update_code_filenames(PyCodeObject *co, PyObject *oldname, PyObject *newname)
if (PyUnicode_Compare(co->co_filename, oldname))
return;
- tmp = co->co_filename;
- co->co_filename = newname;
- Py_INCREF(co->co_filename);
- Py_DECREF(tmp);
+ Py_INCREF(newname);
+ Py_SETREF(co->co_filename, newname);
constants = co->co_consts;
n = PyTuple_GET_SIZE(constants);
@@ -1327,10 +1325,8 @@ remove_importlib_frames(void)
(always_trim ||
PyUnicode_CompareWithASCIIString(code->co_name,
remove_frames) == 0)) {
- PyObject *tmp = *outer_link;
- *outer_link = next;
Py_XINCREF(next);
- Py_DECREF(tmp);
+ Py_SETREF(*outer_link, next);
prev_link = outer_link;
}
else {
diff --git a/Python/peephole.c b/Python/peephole.c
index 59ad3b7..4bf786e 100644
--- a/Python/peephole.c
+++ b/Python/peephole.c
@@ -118,9 +118,7 @@ tuple_of_constants(unsigned char *codestr, Py_ssize_t n,
/* If it's a BUILD_SET, use the PyTuple we just built to create a
PyFrozenSet, and use that as the constant instead: */
if (codestr[0] == BUILD_SET) {
- PyObject *tuple = newconst;
- newconst = PyFrozenSet_New(tuple);
- Py_DECREF(tuple);
+ Py_SETREF(newconst, PyFrozenSet_New(newconst));
if (newconst == NULL)
return 0;
}
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index f784f75..53dd4a1 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -436,10 +436,7 @@ trace_trampoline(PyObject *self, PyFrameObject *frame,
return -1;
}
if (result != Py_None) {
- PyObject *temp = frame->f_trace;
- frame->f_trace = NULL;
- Py_XDECREF(temp);
- frame->f_trace = result;
+ Py_SETREF(frame->f_trace, result);
}
else {
Py_DECREF(result);