mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
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.
This commit is contained in:
parent
f50b38a11f
commit
79ec55e980
6 changed files with 192 additions and 3 deletions
|
@ -231,6 +231,13 @@ PyAPI_FUNC(PyObject *) PyErr_Format(
|
|||
...
|
||||
);
|
||||
|
||||
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_SetExcFromWindowsErrWithUnicodeFilename(
|
|||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue