Mercurial > cpython-lru_cache-weakref
diff Python/errors.c @ 12559:3b8d9e63e4e1 legacy-trunk
PyErr_GivenExceptionMatches(): Check for err==NULL and exc==NULL and
return 0 (exceptions don't match). This means that if an ImportError
is raised because exceptions.py can't be imported, the interpreter
will exit "cleanly" with an error message instead of just core
dumping.
PyErr_SetFromErrnoWithFilename(), PyErr_SetFromWindowsErrWithFilename():
Don't test on Py_UseClassExceptionsFlag.
| author | Barry Warsaw <barry@python.org> |
|---|---|
| date | Tue, 02 May 2000 19:27:51 +0000 |
| parents | 723efcdcce1b |
| children | 916fb024ce94 |
line wrap: on
line diff
--- a/Python/errors.c Tue May 02 19:24:39 2000 +0000 +++ b/Python/errors.c Tue May 02 19:27:51 2000 +0000 @@ -125,6 +125,10 @@ PyErr_GivenExceptionMatches(err, exc) PyObject *err, *exc; { + if (err == NULL || exc == NULL) { + /* maybe caused by "import exceptions" that failed early on */ + return 0; + } if (PyTuple_Check(exc)) { int i, n; n = PyTuple_Size(exc); @@ -331,7 +335,7 @@ } } #endif - if (filename != NULL && Py_UseClassExceptionsFlag) + if (filename != NULL) v = Py_BuildValue("(iss)", i, s, filename); else v = Py_BuildValue("(is)", i, s); @@ -379,7 +383,7 @@ /* remove trailing cr/lf and dots */ while (len > 0 && (s[len-1] <= ' ' || s[len-1] == '.')) s[--len] = '\0'; - if (filename != NULL && Py_UseClassExceptionsFlag) + if (filename != NULL) v = Py_BuildValue("(iss)", err, s, filename); else v = Py_BuildValue("(is)", err, s);
