Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 36b8f94

Browse files
committed
PyErr_Print(): Use PyErr_GivenExceptionMatches() instead of pointer
compares to test for SystemExit and SyntaxError.
1 parent 26726fe commit 36b8f94

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Python/pythonrun.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ PyErr_Print()
530530
PyErr_Fetch(&exception, &v, &tb);
531531
if (exception == NULL)
532532
return;
533-
if (exception == PyExc_SystemExit) {
533+
if (PyErr_GivenExceptionMatches(exception, PyExc_SystemExit)) {
534534
err = Py_FlushLine();
535535
fflush(stdout);
536536
if (v == NULL || v == Py_None)
@@ -555,7 +555,9 @@ PyErr_Print()
555555
fflush(stdout);
556556
if (err == 0)
557557
err = PyTraceBack_Print(tb, f);
558-
if (err == 0 && exception == PyExc_SyntaxError) {
558+
if (err == 0 &&
559+
PyErr_GivenExceptionMatches(exception, PyExc_SyntaxError))
560+
{
559561
PyObject *message;
560562
char *filename, *text;
561563
int lineno, offset;

0 commit comments

Comments
 (0)