summaryrefslogtreecommitdiffstats
path: root/Python/import.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-07-16 04:44:25 (GMT)
committerGitHub <noreply@github.com>2017-07-16 04:44:25 (GMT)
commit28343e3392ca7b1ec7151f68d4d92c90efb91e50 (patch)
treebb3e51c35c23b66403fbf7460c9e595b3fa5368e /Python/import.c
parent65de1f3672fd0a1e3ec34b654ef5213e15a03e26 (diff)
downloadcpython-28343e3392ca7b1ec7151f68d4d92c90efb91e50.zip
cpython-28343e3392ca7b1ec7151f68d4d92c90efb91e50.tar.gz
cpython-28343e3392ca7b1ec7151f68d4d92c90efb91e50.tar.bz2
[3.6] bpo-30876: Relative import from unloaded package now reimports the package (GH-2639) (#2676)
instead of failing with SystemError. Relative import from non-package now fails with ImportError rather than SystemError. (cherry picked from commit 8a9cd20edca7d01b68292036029ae3735ce65edd)
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c7
1 files changed, 0 insertions, 7 deletions
diff --git a/Python/import.c b/Python/import.c
index 40e02c0..4b3bedf 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1345,7 +1345,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;
@@ -1449,12 +1448,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);