summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-10-10 22:23:42 +0300
committerGitHub <noreply@github.com>2020-10-10 22:23:42 +0300
commit98c4433a81a4cd88c7438adbee1f2aa486188ca3 (patch)
tree68dd030d113eb842692d4f50475992a110fb7154 /Python/pythonrun.c
parent02a1603f918b9862e164e4fd050c505b16bc9f57 (diff)
downloadcpython-git-98c4433a81a4cd88c7438adbee1f2aa486188ca3.tar.gz
bpo-41991: Remove _PyObject_HasAttrId (GH-22629)
It can silence arbitrary exceptions.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index ff80103050..a45ca3b183 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -770,7 +770,7 @@ static void
print_exception(PyObject *f, PyObject *value)
{
int err = 0;
- PyObject *type, *tb;
+ PyObject *type, *tb, *tmp;
_Py_IDENTIFIER(print_file_and_line);
if (!PyExceptionInstance_Check(value)) {
@@ -789,10 +789,12 @@ print_exception(PyObject *f, PyObject *value)
if (tb && tb != Py_None)
err = PyTraceBack_Print(tb, f);
if (err == 0 &&
- _PyObject_HasAttrId(value, &PyId_print_file_and_line))
+ (err = _PyObject_LookupAttrId(value, &PyId_print_file_and_line, &tmp)) > 0)
{
PyObject *message, *filename, *text;
Py_ssize_t lineno, offset;
+ err = 0;
+ Py_DECREF(tmp);
if (!parse_syntax_error(value, &message, &filename,
&lineno, &offset, &text))
PyErr_Clear();