[pypy-commit] pypy py3.5: obscure, python 3.5.2 has a different message than 3.5.3

plan_rich pypy.commits at gmail.com
Wed Feb 22 09:52:58 EST 2017


Author: Richard Plangger <planrichi at gmail.com>
Branch: py3.5
Changeset: r90300:4d3783a2d4a2
Date: 2017-02-22 15:50 +0100
http://bitbucket.org/pypy/pypy/changeset/4d3783a2d4a2/

Log:	obscure, python 3.5.2 has a different message than 3.5.3

diff --git a/lib-python/3/test/test_builtin.py b/lib-python/3/test/test_builtin.py
--- a/lib-python/3/test/test_builtin.py
+++ b/lib-python/3/test/test_builtin.py
@@ -1475,6 +1475,8 @@
             with self.assertRaisesRegex(TypeError,
                                         r'\b%s\b' % re.escape(cls.__name__)):
                 format(obj, 's')
+
+
         # --------------------------------------------------------------------
 
         # make sure we can take a subclass of str as a format spec
diff --git a/pypy/objspace/std/objectobject.py b/pypy/objspace/std/objectobject.py
--- a/pypy/objspace/std/objectobject.py
+++ b/pypy/objspace/std/objectobject.py
@@ -221,7 +221,8 @@
         raise oefmt(space.w_TypeError, "format_spec must be a string")
     if space.len_w(w_format_spec) > 0:
         raise oefmt(space.w_TypeError,
-                    "non-empty format string passed to object.__format__")
+                     "unsupported format string passed to %T.__format__",
+                     w_obj);
     return space.format(w_as_str, w_format_spec)
 
 def descr__eq__(space, w_self, w_other):
diff --git a/pypy/objspace/std/test/test_obj.py b/pypy/objspace/std/test/test_obj.py
--- a/pypy/objspace/std/test/test_obj.py
+++ b/pypy/objspace/std/test/test_obj.py
@@ -97,6 +97,16 @@
         assert res == "Pickle"
         assert isinstance(res, str)
 
+    def test_format(self):
+        class B:
+            pass
+        try:
+            format(B(), 's')
+            assert False, "must not pass the previous call"
+        except TypeError as e:
+            assert 'B.__format__' in str(e)
+
+
     def test_subclasshook(self):
         class x(object):
             pass


More information about the pypy-commit mailing list