]> granicus.if.org Git - python/commitdiff
New functions for extension writers on Windows:
authorThomas Heller <theller@ctypes.org>
Mon, 29 Jul 2002 14:27:41 +0000 (14:27 +0000)
committerThomas Heller <theller@ctypes.org>
Mon, 29 Jul 2002 14:27:41 +0000 (14:27 +0000)
 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.

Doc/api/exceptions.tex
Include/pyerrors.h
Misc/NEWS
Python/errors.c

index 7375dd7d720122ca843b88f466b267b26ba3c9dd..f4e4ef0288a0bd2e849fdf74c0c416e2cfa600b8 100644 (file)
@@ -208,6 +208,14 @@ for each thread.
   Availability: Windows.
 \end{cfuncdesc}
 
+\begin{cfuncdesc}{PyObject*}{PyErr_SetExcFromWindowsErr}{PyObject *type,
+                                                        int ierr}
+  Similar to \cfunction{PyErr_SetFromWindowsErr()}, with an additional
+  parameter specifying the exception type to be raised.
+  Availability: Windows.
+  \versionadded{2.3}
+\end{cfuncdesc}
+
 \begin{cfuncdesc}{PyObject*}{PyErr_SetFromWindowsErrWithFilename}{int ierr,
                                                                 char *filename}
   Similar to \cfunction{PyErr_SetFromWindowsErr()}, with the
@@ -217,6 +225,14 @@ for each thread.
   Availability: Windows.
 \end{cfuncdesc}
 
+\begin{cfuncdesc}{PyObject*}{PyErr_SetExcFromWindowsErrWithFilename}
+       {PyObject *type, int ierr, char *filename}
+  Similar to \cfunction{PyErr_SetFromWindowsErrWithFilename()}, with
+  an additional parameter specifying the exception type to be raised.
+  Availability: Windows.
+  \versionadded{2.3}
+\end{cfuncdesc}
+
 \begin{cfuncdesc}{void}{PyErr_BadInternalCall}{}
   This is a shorthand for \samp{PyErr_SetString(PyExc_TypeError,
   \var{message})}, where \var{message} indicates that an internal
index fa5634a31f61a1f50a68b1e5b08d5a110f0d0fd5..f06d38ca5de0b35f4c233d1678427d86681251b6 100644 (file)
@@ -83,6 +83,9 @@ extern DL_IMPORT(PyObject *) PyErr_Format(PyObject *, const char *, ...)
 #ifdef MS_WINDOWS
 extern DL_IMPORT(PyObject *) PyErr_SetFromWindowsErrWithFilename(int, const char *);
 extern DL_IMPORT(PyObject *) PyErr_SetFromWindowsErr(int);
+extern DL_IMPORT(PyObject *) PyErr_SetExcFromWindowsErrWithFilename(
+       PyObject *,int, const char *);
+extern DL_IMPORT(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int);
 #endif
 
 /* Export the old function so that the existing API remains available: */
index f7a0bcd42b54949415582e69c082f25a4bb9d2a3..710b748904e7df6821b88bd3a406c56eaa1ee730 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -380,6 +380,12 @@ Build
 
 C API
 
+- New functions PyErr_SetExcFromWindowsErr() and
+  PyErr_SetExcFromWindowsErrWithFilename(). Similar to
+  PyErr_SetFromWindowsErrWithFilename() and
+  PyErr_SetFromWindowsErr(), but they allow to specify
+  the exception type to raise. Available on Windows.
+
 - Py_FatalError() is now declared as taking a const char* argument.  It
   was previously declared without const.  This should not affect working
   code.
index f744ad46538a3950af5354a1b1f162f19e9111c4..61d1df0d75aafd515044993bc0a17ccfccb63590 100644 (file)
@@ -337,7 +337,8 @@ PyErr_SetFromErrno(PyObject *exc)
 
 #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 @@ PyObject *PyErr_SetFromWindowsErrWithFilename(
        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 */