summaryrefslogtreecommitdiffstats
path: root/Python/import.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-09-06 06:09:31 (GMT)
committerGeorg Brandl <georg@python.org>2006-09-06 06:09:31 (GMT)
commit98775dfebc86aca40b27dcca5e4f4fd3a07e8acb (patch)
tree74d8ab4bfeeb6bdf8c7aaa87221396d38530f8c5 /Python/import.c
parent74bb783c2fd8084a835b6663abe5b70c55fa999d (diff)
downloadcpython-98775dfebc86aca40b27dcca5e4f4fd3a07e8acb.zip
cpython-98775dfebc86aca40b27dcca5e4f4fd3a07e8acb.tar.gz
cpython-98775dfebc86aca40b27dcca5e4f4fd3a07e8acb.tar.bz2
Bug #1550983: emit better error messages for erroneous relative
imports (if not in package and if beyond toplevel package).
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c
index a0c5055..5af3651 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -2114,7 +2114,7 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
size_t len;
if (lastdot == NULL && level > 0) {
PyErr_SetString(PyExc_ValueError,
- "Relative importpath too deep");
+ "Attempted relative import in non-package");
return NULL;
}
if (lastdot == NULL)
@@ -2133,7 +2133,8 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
char *dot = strrchr(buf, '.');
if (dot == NULL) {
PyErr_SetString(PyExc_ValueError,
- "Relative importpath too deep");
+ "Attempted relative import beyond "
+ "toplevel package");
return NULL;
}
*dot = '\0';