diff options
author | Barry Warsaw <barry@python.org> | 2000-05-02 19:27:51 +0000 |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2000-05-02 19:27:51 +0000 |
commit | fa5c315afa39c264e422336cc017853629cb680c (patch) | |
tree | e7a3cfadcf0d2b0cf36e8f6929a4cb9749748eda /Python | |
parent | 48719d3d1f116f6432040fea1754692038ba227c (diff) | |
download | cpython-git-fa5c315afa39c264e422336cc017853629cb680c.tar.gz |
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.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/errors.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/errors.c b/Python/errors.c index ebce5ddbb3..d05a21d5ba 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -125,6 +125,10 @@ int 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 @@ PyErr_SetFromErrnoWithFilename(exc, filename) } } #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 @@ PyObject *PyErr_SetFromWindowsErrWithFilename( /* 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); |