mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
Add PyExc_ImportCycleError and raise it when a cycle is detected
This commit is contained in:
parent
00e7800e4c
commit
781eedb9d4
9 changed files with 57 additions and 15 deletions
|
|
@ -1958,6 +1958,12 @@ static PyTypeObject _PyExc_ImportError = {
|
|||
};
|
||||
PyObject *PyExc_ImportError = (PyObject *)&_PyExc_ImportError;
|
||||
|
||||
/*
|
||||
* ImportCycleError extends ImportError
|
||||
*/
|
||||
|
||||
MiddlingExtendsException(PyExc_ImportError, ImportCycleError, ImportError,
|
||||
"Import produces a cycle.");
|
||||
/*
|
||||
* ModuleNotFoundError extends ImportError
|
||||
*/
|
||||
|
|
@ -4391,6 +4397,7 @@ static struct static_exception static_exceptions[] = {
|
|||
{&_PyExc_IncompleteInputError, "_IncompleteInputError"}, // base: SyntaxError(Exception)
|
||||
ITEM(IndexError), // base: LookupError(Exception)
|
||||
ITEM(KeyError), // base: LookupError(Exception)
|
||||
ITEM(ImportCycleError), // base: ImportError(Exception)
|
||||
ITEM(ModuleNotFoundError), // base: ImportError(Exception)
|
||||
ITEM(NotImplementedError), // base: RuntimeError(Exception)
|
||||
ITEM(PythonFinalizationError), // base: RuntimeError(Exception)
|
||||
|
|
@ -4586,4 +4593,3 @@ _PyException_AddNote(PyObject *exc, PyObject *note)
|
|||
Py_XDECREF(r);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue