comparison Python/pythonrun.c @ 6165:29ddf1049842 legacy-trunk

PyErr_Print(): Use PyErr_GivenExceptionMatches() instead of pointer compares to test for SystemExit and SyntaxError.
author Barry Warsaw <barry@python.org>
date Tue, 26 Aug 1997 18:09:48 +0000
parents 57045f51dd12
children 7da7ba5c6525
comparison
equal deleted inserted replaced
6164:3ec5ca8af91d 6165:29ddf1049842
528 int err = 0; 528 int err = 0;
529 PyObject *exception, *v, *tb, *f; 529 PyObject *exception, *v, *tb, *f;
530 PyErr_Fetch(&exception, &v, &tb); 530 PyErr_Fetch(&exception, &v, &tb);
531 if (exception == NULL) 531 if (exception == NULL)
532 return; 532 return;
533 if (exception == PyExc_SystemExit) { 533 if (PyErr_GivenExceptionMatches(exception, PyExc_SystemExit)) {
534 err = Py_FlushLine(); 534 err = Py_FlushLine();
535 fflush(stdout); 535 fflush(stdout);
536 if (v == NULL || v == Py_None) 536 if (v == NULL || v == Py_None)
537 Py_Exit(0); 537 Py_Exit(0);
538 if (PyInt_Check(v)) 538 if (PyInt_Check(v))
553 else { 553 else {
554 err = Py_FlushLine(); 554 err = Py_FlushLine();
555 fflush(stdout); 555 fflush(stdout);
556 if (err == 0) 556 if (err == 0)
557 err = PyTraceBack_Print(tb, f); 557 err = PyTraceBack_Print(tb, f);
558 if (err == 0 && exception == PyExc_SyntaxError) { 558 if (err == 0 &&
559 PyErr_GivenExceptionMatches(exception, PyExc_SyntaxError))
560 {
559 PyObject *message; 561 PyObject *message;
560 char *filename, *text; 562 char *filename, *text;
561 int lineno, offset; 563 int lineno, offset;
562 if (!PyArg_Parse(v, "(O(ziiz))", &message, 564 if (!PyArg_Parse(v, "(O(ziiz))", &message,
563 &filename, &lineno, &offset, &text)) 565 &filename, &lineno, &offset, &text))