summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-12-27 15:44:33 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2015-12-27 15:44:33 +0200
commit092d79a99eef395c1915619b7069a873d958a04c (patch)
tree0c70eff46bc128e4231ce12fb3d1624fa7f00d01 /Python
parentc83f0d1df50154f93c263b82fd8f3ad43913bc65 (diff)
parent38f3c4611a7ed03dddc07fbd568b619af8b139a4 (diff)
downloadcpython-092d79a99eef395c1915619b7069a873d958a04c.tar.gz
Issue #20440: More use of Py_SETREF.
This patch is manually crafted and contains changes that couldn't be handled automatically.
Diffstat (limited to 'Python')
-rw-r--r--Python/ast.c10
-rw-r--r--Python/errors.c13
2 files changed, 8 insertions, 15 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 328ee5d914..33f2597fc0 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -4496,8 +4496,7 @@ fstring_find_literal_and_expr(PyObject *str, Py_ssize_t *ofs, int recurse_lvl,
return 0;
error:
- Py_XDECREF(*literal);
- *literal = NULL;
+ Py_CLEAR(*literal);
return -1;
}
@@ -4692,11 +4691,8 @@ FstringParser_ConcatAndDel(FstringParser *state, PyObject *str)
state->last_str = str;
} else {
/* Concatenate this with the previous string. */
- PyObject *temp = PyUnicode_Concat(state->last_str, str);
- Py_DECREF(state->last_str);
- Py_DECREF(str);
- state->last_str = temp;
- if (!temp)
+ PyUnicode_AppendAndDel(&state->last_str, str);
+ if (!state->last_str)
return -1;
}
FstringParser_check_invariants(state);
diff --git a/Python/errors.c b/Python/errors.c
index aed2bdc12d..7b67566727 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -315,14 +315,11 @@ finally:
tstate = PyThreadState_GET();
if (++tstate->recursion_depth > Py_GetRecursionLimit()) {
--tstate->recursion_depth;
- /* throw away the old exception... */
- Py_DECREF(*exc);
- Py_DECREF(*val);
- /* ... and use the recursion error instead */
- *exc = PyExc_RecursionError;
- *val = PyExc_RecursionErrorInst;
- Py_INCREF(*exc);
- Py_INCREF(*val);
+ /* throw away the old exception and use the recursion error instead */
+ Py_INCREF(PyExc_RecursionError);
+ Py_SETREF(*exc, PyExc_RecursionError);
+ Py_INCREF(PyExc_RecursionErrorInst);
+ Py_SETREF(*val, PyExc_RecursionErrorInst);
/* just keeping the old traceback */
return;
}