summaryrefslogtreecommitdiff
path: root/Python/errors.c
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@python.org>2020-10-19 15:50:36 +0100
committerGitHub <noreply@github.com>2020-10-19 15:50:36 +0100
commitc82f10450c547eb94a04ee17b7c816ff31948297 (patch)
treead305c05c5745e1a5e7c136545bec7eefa741e32 /Python/errors.c
parenteee6bb50c69d94280f43b47390ea9d1b5f42930c (diff)
parentb580ed1d9d55461d8dde027411b90be26cae131e (diff)
downloadcpython-git-bpo-39107.tar.gz
Merge branch 'master' into bpo-39107bpo-39107
Diffstat (limited to 'Python/errors.c')
-rw-r--r--Python/errors.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/Python/errors.c b/Python/errors.c
index 720f18bc22..02cf47992b 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -1593,9 +1593,18 @@ PyErr_SyntaxLocationObject(PyObject *filename, int lineno, int col_offset)
}
Py_DECREF(tmp);
}
+ else {
+ _PyErr_Clear(tstate);
+ }
}
if (exc != PyExc_SyntaxError) {
- if (!_PyObject_HasAttrId(v, &PyId_msg)) {
+ if (_PyObject_LookupAttrId(v, &PyId_msg, &tmp) < 0) {
+ _PyErr_Clear(tstate);
+ }
+ else if (tmp) {
+ Py_DECREF(tmp);
+ }
+ else {
tmp = PyObject_Str(v);
if (tmp) {
if (_PyObject_SetAttrId(v, &PyId_msg, tmp)) {
@@ -1607,7 +1616,13 @@ PyErr_SyntaxLocationObject(PyObject *filename, int lineno, int col_offset)
_PyErr_Clear(tstate);
}
}
- if (!_PyObject_HasAttrId(v, &PyId_print_file_and_line)) {
+ if (_PyObject_LookupAttrId(v, &PyId_print_file_and_line, &tmp) < 0) {
+ _PyErr_Clear(tstate);
+ }
+ else if (tmp) {
+ Py_DECREF(tmp);
+ }
+ else {
if (_PyObject_SetAttrId(v, &PyId_print_file_and_line,
Py_None)) {
_PyErr_Clear(tstate);