diff Include/pyerrors.h @ 76272:6825fd9b00ed

Issue #1559549: Add 'name' and 'path' attributes to ImportError. Currently import does not use these attributes as they are planned for use by importlib (which will be another commit). Thanks to Filip GruszczyƄski for the initial patch and Brian Curtin for refining it.
author Brett Cannon <brett@python.org>
date Thu, 12 Apr 2012 20:24:54 -0400
parents b299c4f31ff2
children be0ab722c43d
line wrap: on
line diff
--- a/Include/pyerrors.h	Thu Apr 12 18:44:58 2012 -0400
+++ b/Include/pyerrors.h	Thu Apr 12 20:24:54 2012 -0400
@@ -231,6 +231,13 @@
     ...
     );
 
+typedef struct {
+    PyException_HEAD
+    PyObject *msg;
+    PyObject *name;
+    PyObject *path;
+} PyImportErrorObject;
+
 #ifdef MS_WINDOWS
 PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename(
     int ierr,
@@ -256,6 +263,12 @@
 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int);
 #endif /* MS_WINDOWS */
 
+PyAPI_FUNC(PyObject *) PyErr_SetExcWithArgsKwargs(PyObject *, PyObject *,
+    PyObject *);
+PyAPI_FUNC(PyObject *) PyErr_SetFromImportErrorWithNameAndPath(PyObject *,
+        PyObject *, PyObject *);
+PyAPI_FUNC(PyObject *) PyErr_SetFromImportErrorWithName(PyObject *, PyObject *);
+
 /* Export the old function so that the existing API remains available: */
 PyAPI_FUNC(void) PyErr_BadInternalCall(void);
 PyAPI_FUNC(void) _PyErr_BadInternalCall(const char *filename, int lineno);