comparison 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
comparison
equal deleted inserted replaced
9364:9f135b3d9a78 9365:c80321c328b5
280 PyErr_SetFromErrnoWithFilename(exc, filename) 280 PyErr_SetFromErrnoWithFilename(exc, filename)
281 PyObject *exc; 281 PyObject *exc;
282 char *filename; 282 char *filename;
283 { 283 {
284 PyObject *v; 284 PyObject *v;
285 char *s;
285 int i = errno; 286 int i = errno;
286 #ifdef EINTR 287 #ifdef EINTR
287 if (i == EINTR && PyErr_CheckSignals()) 288 if (i == EINTR && PyErr_CheckSignals())
288 return NULL; 289 return NULL;
289 #endif 290 #endif
291 if (i == 0)
292 s = "Error"; /* Sometimes errno didn't get set */
293 else
294 s = strerror(i);
290 if (filename != NULL && Py_UseClassExceptionsFlag) 295 if (filename != NULL && Py_UseClassExceptionsFlag)
291 v = Py_BuildValue("(iss)", i, strerror(i), filename); 296 v = Py_BuildValue("(iss)", i, s, filename);
292 else 297 else
293 v = Py_BuildValue("(is)", i, strerror(i)); 298 v = Py_BuildValue("(is)", i, s);
294 if (v != NULL) { 299 if (v != NULL) {
295 PyErr_SetObject(exc, v); 300 PyErr_SetObject(exc, v);
296 Py_DECREF(v); 301 Py_DECREF(v);
297 } 302 }
298 return NULL; 303 return NULL;