diff options
author | Guido van Rossum <guido@python.org> | 1998-10-14 20:38:13 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-10-14 20:38:13 (GMT) |
commit | e0e59829e006ddf670d0cbffa9b9d00b71227d70 (patch) | |
tree | e234d1888443aedbaca22963daa3feff43cefa3c /Python | |
parent | b0e5718643f807af590e16ebb8d3eb401a327ca3 (diff) | |
download | cpython-e0e59829e006ddf670d0cbffa9b9d00b71227d70.zip cpython-e0e59829e006ddf670d0cbffa9b9d00b71227d70.tar.gz cpython-e0e59829e006ddf670d0cbffa9b9d00b71227d70.tar.bz2 |
When errno is zero, avoid calling strerror() and use "Error" for the
message.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/errors.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Python/errors.c b/Python/errors.c index c0efbf1..423f792 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -282,15 +282,20 @@ PyErr_SetFromErrnoWithFilename(exc, filename) char *filename; { PyObject *v; + char *s; int i = errno; #ifdef EINTR if (i == EINTR && PyErr_CheckSignals()) return NULL; #endif + if (i == 0) + s = "Error"; /* Sometimes errno didn't get set */ + else + s = strerror(i); if (filename != NULL && Py_UseClassExceptionsFlag) - v = Py_BuildValue("(iss)", i, strerror(i), filename); + v = Py_BuildValue("(iss)", i, s, filename); else - v = Py_BuildValue("(is)", i, strerror(i)); + v = Py_BuildValue("(is)", i, s); if (v != NULL) { PyErr_SetObject(exc, v); Py_DECREF(v); |