]> granicus.if.org Git - python/commitdiff
Bug #1550983: emit better error messages for erroneous relative
authorGeorg Brandl <georg@python.org>
Wed, 6 Sep 2006 06:09:34 +0000 (06:09 +0000)
committerGeorg Brandl <georg@python.org>
Wed, 6 Sep 2006 06:09:34 +0000 (06:09 +0000)
imports (if not in package and if beyond toplevel package).
 (backport from rev. 51765)

Misc/NEWS
Python/import.c

index fe0308742d0068a4390e95d5f91820de6c46b09d..ceb26a109453a48d03c59f40f889b659d9089c92 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -19,6 +19,9 @@ What's New in Python 2.5 release candidate 2?
 Core and builtins
 -----------------
 
+- Bug #1550983: emit better error messages for erroneous relative
+  imports (if not in package and if beyond toplevel package).
+
 - Overflow checking code in integer division ran afoul of new gcc
   optimizations.  Changed to be more standard-conforming.
 
index a0c5055142bce0c2da8d855cd002533d895307d0..5af365187ec5fc8ee6d4db9005a1036e64da9dee 100644 (file)
@@ -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';