diff Python/import.c @ 39777:307a11c085b4 legacy-trunk

Bug #1550983: emit better error messages for erroneous relative imports (if not in package and if beyond toplevel package).
author Georg Brandl <georg@python.org>
date Wed, 06 Sep 2006 06:09:31 +0000
parents 8dcb882ec3e1
children 66d0357029b5
line wrap: on
line diff
--- a/Python/import.c	Wed Sep 06 06:03:59 2006 +0000
+++ b/Python/import.c	Wed Sep 06 06:09:31 2006 +0000
@@ -2114,7 +2114,7 @@
 		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 @@
 		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';