Mercurial > cpython-lru_cache-weakref
diff Python/errors.c @ 9365:c80321c328b5 legacy-trunk
When errno is zero, avoid calling strerror() and use "Error" for the
message.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 14 Oct 1998 20:38:13 +0000 |
| parents | ca1c669bb041 |
| children | 1d40bc25703a |
line wrap: on
line diff
--- a/Python/errors.c Wed Oct 14 20:27:05 1998 +0000 +++ b/Python/errors.c Wed Oct 14 20:38:13 1998 +0000 @@ -282,15 +282,20 @@ 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);
