[Python-checkins] r51766 - in python/branches/release25-maint: Misc/NEWS Python/import.c

georg.brandl python-checkins at python.org
Wed Sep 6 08:09:35 CEST 2006


Author: georg.brandl
Date: Wed Sep  6 08:09:34 2006
New Revision: 51766

Modified:
   python/branches/release25-maint/Misc/NEWS
   python/branches/release25-maint/Python/import.c
Log:
Bug #1550983: emit better error messages for erroneous relative
imports (if not in package and if beyond toplevel package).
 (backport from rev. 51765)

Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS	(original)
+++ python/branches/release25-maint/Misc/NEWS	Wed Sep  6 08:09:34 2006
@@ -19,6 +19,9 @@
 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.
 

Modified: python/branches/release25-maint/Python/import.c
==============================================================================
--- python/branches/release25-maint/Python/import.c	(original)
+++ python/branches/release25-maint/Python/import.c	Wed Sep  6 08:09:34 2006
@@ -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';


More information about the Python-checkins mailing list