Skip to content

Commit

Permalink
When errno is zero, avoid calling strerror() and use "Error" for the
Browse files Browse the repository at this point in the history
message.
  • Loading branch information
gvanrossum committed Oct 14, 1998
1 parent b0e5718 commit e0e5982
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Python/errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e0e5982

Please sign in to comment.