Mercurial > cpython-lru_cache-weakref
diff Python/errors.c @ 24423:3db261a93a5b legacy-trunk
New functions for extension writers on Windows:
PyErr_SetExcFromWindowsErr(), PyErr_SetExcFromWindowsErrWithFilename().
Similar to PyErr_SetFromWindowsErrWithFilename() and
PyErr_SetFromWindowsErr(), but they allow to specify
the exception type to raise. Available on Windows.
See SF patch #576458.
| author | Thomas Heller <theller@ctypes.org> |
|---|---|
| date | Mon, 29 Jul 2002 14:27:41 +0000 |
| parents | 8142f8d668a0 |
| children | 861065256487 |
line wrap: on
line diff
--- a/Python/errors.c Mon Jul 29 14:05:24 2002 +0000 +++ b/Python/errors.c Mon Jul 29 14:27:41 2002 +0000 @@ -337,7 +337,8 @@ #ifdef MS_WINDOWS /* Windows specific error code handling */ -PyObject *PyErr_SetFromWindowsErrWithFilename( +PyObject *PyErr_SetExcFromWindowsErrWithFilename( + PyObject *exc, int ierr, const char *filename) { @@ -366,16 +367,29 @@ else v = Py_BuildValue("(is)", err, s); if (v != NULL) { - PyErr_SetObject(PyExc_WindowsError, v); + PyErr_SetObject(exc, v); Py_DECREF(v); } LocalFree(s); return NULL; } +PyObject *PyErr_SetExcFromWindowsErr(PyObject *exc, int ierr) +{ + return PyErr_SetExcFromWindowsErrWithFilename(exc, ierr, NULL); +} + PyObject *PyErr_SetFromWindowsErr(int ierr) { - return PyErr_SetFromWindowsErrWithFilename(ierr, NULL); + return PyErr_SetExcFromWindowsErrWithFilename(PyExc_WindowsError, + ierr, NULL); +} +PyObject *PyErr_SetFromWindowsErrWithFilename( + int ierr, + const char *filename) +{ + return PyErr_SetExcFromWindowsErrWithFilename(PyExc_WindowsError, + ierr, filename); } #endif /* MS_WINDOWS */
