mirror of https://github.com/python/cpython
Bug #1550983: emit better error messages for erroneous relative
imports (if not in package and if beyond toplevel package). (backport from rev. 51765)
This commit is contained in:
parent
b20cb33f7f
commit
37a9e579ec
|
@ -19,6 +19,9 @@ What's New in Python 2.5 release candidate 2?
|
||||||
Core and builtins
|
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
|
- Overflow checking code in integer division ran afoul of new gcc
|
||||||
optimizations. Changed to be more standard-conforming.
|
optimizations. Changed to be more standard-conforming.
|
||||||
|
|
||||||
|
|
|
@ -2114,7 +2114,7 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
|
||||||
size_t len;
|
size_t len;
|
||||||
if (lastdot == NULL && level > 0) {
|
if (lastdot == NULL && level > 0) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"Relative importpath too deep");
|
"Attempted relative import in non-package");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (lastdot == 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, '.');
|
char *dot = strrchr(buf, '.');
|
||||||
if (dot == NULL) {
|
if (dot == NULL) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"Relative importpath too deep");
|
"Attempted relative import beyond "
|
||||||
|
"toplevel package");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*dot = '\0';
|
*dot = '\0';
|
||||||
|
|
Loading…
Reference in New Issue