Author: Ronan Lamy <[email protected]>
Branch: py3.6
Changeset: r97386:fbdb61ac5e0b
Date: 2019-09-06 10:35 +0000
http://bitbucket.org/pypy/pypy/changeset/fbdb61ac5e0b/

Log:    Merged in paugier/pypy/py3.6 (pull request #663)

        Add parentheses to an error message: "__prepare__() must return a
        mapping..."

diff --git a/pypy/module/__builtin__/compiling.py 
b/pypy/module/__builtin__/compiling.py
--- a/pypy/module/__builtin__/compiling.py
+++ b/pypy/module/__builtin__/compiling.py
@@ -133,11 +133,11 @@
     if not space.ismapping_w(w_namespace):
         if isclass:
             raise oefmt(space.w_TypeError,
-                "%N.__prepare__ must return a mapping, not %T",
+                "%N.__prepare__() must return a mapping, not %T",
                 w_meta, w_namespace)
         else:
             raise oefmt(space.w_TypeError,
-                "<metaclass>.__prepare__ must return a mapping, not %T",
+                "<metaclass>.__prepare__() must return a mapping, not %T",
                 w_namespace)
 
     code = w_func.getcode()
diff --git a/pypy/module/__builtin__/test/apptest_compile.py 
b/pypy/module/__builtin__/test/apptest_compile.py
--- a/pypy/module/__builtin__/test/apptest_compile.py
+++ b/pypy/module/__builtin__/test/apptest_compile.py
@@ -179,3 +179,20 @@
         assert 'module_doc' not in marshalled
         assert 'func_doc' not in marshalled
         assert 'class_doc' not in marshalled
+
+def test_build_class():
+    """Test error message bad __prepare__"""
+
+    class BadMeta(type):
+        @classmethod
+        def __prepare__(*args):
+            return None
+
+    def func():
+        class Foo(metaclass=BadMeta):
+            pass
+
+    excinfo = raises(TypeError, func)
+    assert str(excinfo.value) == (
+        r"BadMeta.__prepare__() must return a mapping, not NoneType"
+    )
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to