Kaydet (Commit) e0e59829 authored tarafından Guido van Rossum's avatar Guido van Rossum

When errno is zero, avoid calling strerror() and use "Error" for the

message.
üst b0e57186
...@@ -282,15 +282,20 @@ PyErr_SetFromErrnoWithFilename(exc, filename) ...@@ -282,15 +282,20 @@ PyErr_SetFromErrnoWithFilename(exc, filename)
char *filename; char *filename;
{ {
PyObject *v; PyObject *v;
char *s;
int i = errno; int i = errno;
#ifdef EINTR #ifdef EINTR
if (i == EINTR && PyErr_CheckSignals()) if (i == EINTR && PyErr_CheckSignals())
return NULL; return NULL;
#endif #endif
if (i == 0)
s = "Error"; /* Sometimes errno didn't get set */
else
s = strerror(i);
if (filename != NULL && Py_UseClassExceptionsFlag) if (filename != NULL && Py_UseClassExceptionsFlag)
v = Py_BuildValue("(iss)", i, strerror(i), filename); v = Py_BuildValue("(iss)", i, s, filename);
else else
v = Py_BuildValue("(is)", i, strerror(i)); v = Py_BuildValue("(is)", i, s);
if (v != NULL) { if (v != NULL) {
PyErr_SetObject(exc, v); PyErr_SetObject(exc, v);
Py_DECREF(v); Py_DECREF(v);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment