diff options
author | Georg Brandl <georg@python.org> | 2006-09-06 06:09:34 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-09-06 06:09:34 (GMT) |
commit | 37a9e579ec8eab67e9e73e074deb8900ac72c744 (patch) | |
tree | 2cf0b0dcb5bc3e36e847df952eced42e2293730c /Python/import.c | |
parent | b20cb33f7ff837d6265ac33768b05ec212931a7e (diff) | |
download | cpython-37a9e579ec8eab67e9e73e074deb8900ac72c744.zip cpython-37a9e579ec8eab67e9e73e074deb8900ac72c744.tar.gz cpython-37a9e579ec8eab67e9e73e074deb8900ac72c744.tar.bz2 |
Bug #1550983: emit better error messages for erroneous relative
imports (if not in package and if beyond toplevel package).
(backport from rev. 51765)
Diffstat (limited to 'Python/import.c')
-rw-r--r-- | Python/import.c | 5 |
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'; |