[pypy-svn] pypy default: A test, and a very tentative fix (no clue really, as it depends on
arigo
commits-noreply at bitbucket.org
Thu Mar 17 18:26:01 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r42739:678a07ff0b73
Date: 2011-03-17 13:25 -0400
http://bitbucket.org/pypy/pypy/changeset/678a07ff0b73/
Log: A test, and a very tentative fix (no clue really, as it depends on
the "XXX What is this check about?" already present).
diff --git a/pypy/module/imp/test/test_import.py b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -49,7 +49,8 @@
absolute = "from __future__ import absolute_import\nimport string",
relative_b = "from __future__ import absolute_import\nfrom . import string",
relative_c = "from __future__ import absolute_import\nfrom .string import inpackage",
- relative_f = "from .os import sep",
+ relative_f = "from .imp import get_magic",
+ relative_g = "import imp; from .imp import get_magic",
)
setuppkg("pkg.pkg1",
a = '',
@@ -359,7 +360,13 @@
def imp():
from pkg import relative_f
exc = raises(ImportError, imp)
- assert exc.value.message == "No module named pkg.os"
+ assert exc.value.message == "No module named pkg.imp"
+
+ def test_no_relative_import_bug(self):
+ def imp():
+ from pkg import relative_g
+ exc = raises(ImportError, imp)
+ assert exc.value.message == "No module named pkg.imp"
def test_future_relative_import_level_1(self):
from pkg import relative_c
diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -158,7 +158,8 @@
w_mod = check_sys_modules(space, w(rel_modulename))
if (w_mod is None or
- not space.is_w(w_mod, space.w_None)):
+ not space.is_w(w_mod, space.w_None) or
+ level > 0):
# if no level was set, ignore import errors, and
# fall back to absolute import at the end of the
More information about the Pypy-commit
mailing list