Mercurial > cpython-lru_cache-weakref
diff Python/errors.c @ 8706:ca1c669bb041 legacy-trunk
PyErr_SetFromErrnoWithFilename(): New function which supports setting
an exception from errno, with a supplied filename (primarily used by
IOError and OSError). If class exceptions are used then the exception
is instantiated with a 3-tuple: (errno, strerror, filename). For
backwards compatibility reasons, if string exceptions are used,
filename is ignored.
PyErr_SetFromErrno(): Implement in terms of
PyErr_SetFromErrnoWithFilename().
| author | Barry Warsaw <barry@python.org> |
|---|---|
| date | Thu, 23 Jul 1998 16:05:56 +0000 |
| parents | bb440a2975ab |
| children | c80321c328b5 |
line wrap: on
line diff
--- a/Python/errors.c Thu Jul 23 16:03:46 1998 +0000 +++ b/Python/errors.c Thu Jul 23 16:05:56 1998 +0000 @@ -277,8 +277,9 @@ } PyObject * -PyErr_SetFromErrno(exc) +PyErr_SetFromErrnoWithFilename(exc, filename) PyObject *exc; + char *filename; { PyObject *v; int i = errno; @@ -286,13 +287,24 @@ if (i == EINTR && PyErr_CheckSignals()) return NULL; #endif - v = Py_BuildValue("(is)", i, strerror(i)); + if (filename != NULL && Py_UseClassExceptionsFlag) + v = Py_BuildValue("(iss)", i, strerror(i), filename); + else + v = Py_BuildValue("(is)", i, strerror(i)); if (v != NULL) { PyErr_SetObject(exc, v); Py_DECREF(v); } return NULL; } + + +PyObject * +PyErr_SetFromErrno(exc) + PyObject *exc; +{ + return PyErr_SetFromErrnoWithFilename(exc, NULL); +} void PyErr_BadInternalCall()
