Author: mattip <[email protected]>
Branch: release-pypy2.7-5.x
Changeset: r90884:14f400f0498e
Date: 2017-03-31 18:04 +0300
http://bitbucket.org/pypy/pypy/changeset/14f400f0498e/

Log:    make error message compatible with cpython 2.7.13 (grafted from
        add48f6012a1702abb34076e9fd8a93a11020457)

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
@@ -381,7 +381,7 @@
                     w_name = space.getitem(w_fromlist, space.newint(i))
                     if not space.isinstance_w(w_name, space.w_text):
                         raise oefmt(space.w_TypeError,
-                            "'Item in ``fromlist'' not a string")
+                            "'Item in ``fromlist'' must be str, not %T", 
w_name)
                     if try_getattr(space, w_mod, w_name) is None:
                         return None
         return w_mod
@@ -430,7 +430,7 @@
                     w_name = space.getitem(w_fromlist, space.newint(i))
                     if not space.isinstance_w(w_name, space.w_text):
                         raise oefmt(space.w_TypeError,
-                            "'Item in ``fromlist'' not a string")
+                            "'Item in ``fromlist'' must be str, not %T", 
w_name)
                     if try_getattr(space, w_mod, w_name) is None:
                         load_part(space, w_path, prefix, space.text0_w(w_name),
                                   w_mod, tentative=1)
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
@@ -361,10 +361,14 @@
         assert sys == o
 
     def test_import_fromlist_must_not_contain_unicodes(self):
+        import sys
+        ver = sys.version_info
         exc = raises(TypeError, __import__, 'encodings', None, None, [u'xxx'])
-        assert 'not a string' in exc.value.message
+        if ver > (2, 7, 12):
+            assert 'must be str' in exc.value.message
         exc = raises(TypeError, __import__, 'encodings', None, None, [123])
-        assert 'not a string' in exc.value.message
+        if ver > (2, 7, 12):
+            assert 'must be str' in exc.value.message
         # issue 2524
         raises(ImportError, __import__, 'xxxbadmodule', fromlist=[u'xx']) 
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to