PyFile_FromString(): If an exception occurs, pass in the filename that

was used so it's reflected in the IOError.  Call
PyErr_SetFromErrnoWithFilename().
This commit is contained in:
Barry Warsaw 1998-07-23 16:07:02 +00:00
parent 97d951533e
commit 52ddc0e756
1 changed files with 2 additions and 1 deletions

View File

@ -137,13 +137,14 @@ PyFile_FromString(name, mode)
}
if (f->f_fp == NULL) {
#ifdef NO_FOPEN_ERRNO
/* Metroworks only, not testable, so unchanged */
if ( errno == 0 ) {
PyErr_SetString(PyExc_IOError, "Cannot open file");
Py_DECREF(f);
return NULL;
}
#endif
PyErr_SetFromErrno(PyExc_IOError);
PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
Py_DECREF(f);
return NULL;
}