[pypy-commit] pypy py3.5: The '#c' format is not allowed anymore

amauryfa pypy.commits at gmail.com
Sun Nov 6 12:10:55 EST 2016


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3.5
Changeset: r88155:89f9d1a3ae5a
Date: 2016-11-06 18:09 +0100
http://bitbucket.org/pypy/pypy/changeset/89f9d1a3ae5a/

Log:	The '#c' format is not allowed anymore

diff --git a/pypy/objspace/std/newformat.py b/pypy/objspace/std/newformat.py
--- a/pypy/objspace/std/newformat.py
+++ b/pypy/objspace/std/newformat.py
@@ -762,6 +762,10 @@
                 if self._sign != "\0":
                     raise oefmt(space.w_ValueError,
                                 "sign not allowed with 'c' presentation type")
+                if self._alternate:
+                    raise oefmt(space.w_ValueError,
+                                "Alternate form (#) not allowed "
+                                "with 'c' presentation type")
                 value = space.int_w(w_num)
                 max_char = runicode.MAXUNICODE if self.is_unicode else 0xFF
                 if not (0 <= value <= max_char):
diff --git a/pypy/objspace/std/test/test_newformat.py b/pypy/objspace/std/test/test_newformat.py
--- a/pypy/objspace/std/test/test_newformat.py
+++ b/pypy/objspace/std/test/test_newformat.py
@@ -241,6 +241,7 @@
         assert format(a, "c") == "a"
         raises(ValueError, format, a, "-c")
         raises(ValueError, format, a, ",c")
+        raises(ValueError, format, a, "#c")
         assert format(a, "3c") == "  a"
         assert format(a, "<3c") == "a  "
         assert format(a, "^3c") == " a "


More information about the pypy-commit mailing list