summaryrefslogtreecommitdiffstats
path: root/Objects/fileobject.c
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1998-07-23 16:07:02 (GMT)
committerBarry Warsaw <barry@python.org>1998-07-23 16:07:02 (GMT)
commit52ddc0e7567fb927ca3a5cd1ed4243c3450a552e (patch)
tree20a0705240c69bfe874cc03bd03fb345d62037ea /Objects/fileobject.c
parent97d951533e71b74a1a2502feda4a587eb9fb7d98 (diff)
downloadcpython-52ddc0e7567fb927ca3a5cd1ed4243c3450a552e.zip
cpython-52ddc0e7567fb927ca3a5cd1ed4243c3450a552e.tar.gz
cpython-52ddc0e7567fb927ca3a5cd1ed4243c3450a552e.tar.bz2
PyFile_FromString(): If an exception occurs, pass in the filename that
was used so it's reflected in the IOError. Call PyErr_SetFromErrnoWithFilename().
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r--Objects/fileobject.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index d43f113..d3b9894 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -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;
}