mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
bpo-30876: Relative import from unloaded package now reimports the package (#2639)
instead of failing with SystemError. Relative import from non-package now fails with ImportError rather than SystemError.
This commit is contained in:
@@ -1344,7 +1344,6 @@ resolve_name(PyObject *name, PyObject *globals, int level)
|
||||
PyObject *abs_name;
|
||||
PyObject *package = NULL;
|
||||
PyObject *spec;
|
||||
PyInterpreterState *interp = PyThreadState_GET()->interp;
|
||||
Py_ssize_t last_dot;
|
||||
PyObject *base;
|
||||
int level_up;
|
||||
@@ -1448,12 +1447,6 @@ resolve_name(PyObject *name, PyObject *globals, int level)
|
||||
"attempted relative import with no known parent package");
|
||||
goto error;
|
||||
}
|
||||
else if (PyDict_GetItem(interp->modules, package) == NULL) {
|
||||
PyErr_Format(PyExc_SystemError,
|
||||
"Parent module %R not loaded, cannot perform relative "
|
||||
"import", package);
|
||||
goto error;
|
||||
}
|
||||
|
||||
for (level_up = 1; level_up < level; level_up += 1) {
|
||||
last_dot = PyUnicode_FindChar(package, '.', 0, last_dot, -1);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user