[pypy-commit] pypy stdlib-2.7.11: merged upstream

alex_gaynor pypy.commits at gmail.com
Sun Mar 20 19:45:11 EDT 2016


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: stdlib-2.7.11
Changeset: r83209:c1486e592f6f
Date: 2016-03-20 19:44 -0400
http://bitbucket.org/pypy/pypy/changeset/c1486e592f6f/

Log:	merged upstream

diff --git a/lib-python/2.7/test/test_cpickle.py b/lib-python/2.7/test/test_cpickle.py
--- a/lib-python/2.7/test/test_cpickle.py
+++ b/lib-python/2.7/test/test_cpickle.py
@@ -166,7 +166,9 @@
 for name in dir(AbstractPickleTests):
     if name.startswith('test_recursive_'):
         func = getattr(AbstractPickleTests, name)
-        if '_subclass' in name and '_and_inst' not in name:
+        if (test_support.check_impl_detail(pypy=True) or
+            '_subclass' in name and '_and_inst' not in name):
+            # PyPy's cPickle matches pure python pickle's behavior here
             assert_args = RuntimeError, 'maximum recursion depth exceeded'
         else:
             assert_args = ValueError, "can't pickle cyclic objects"
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
@@ -771,6 +771,11 @@
                     msg = "sign not allowed with 'c' presentation type"
                     raise OperationError(space.w_ValueError, space.wrap(msg))
                 value = space.int_w(w_num)
+                max_char = runicode.MAXUNICODE if self.is_unicode else 0xFF
+                if not (0 <= value <= max_char):
+                    raise oefmt(space.w_OverflowError,
+                                "%%c arg not in range(%s)",
+                                hex(max_char))
                 if self.is_unicode:
                     result = runicode.UNICHR(value)
                 else:
diff --git a/pypy/objspace/std/test/test_bytesobject.py b/pypy/objspace/std/test/test_bytesobject.py
--- a/pypy/objspace/std/test/test_bytesobject.py
+++ b/pypy/objspace/std/test/test_bytesobject.py
@@ -103,6 +103,10 @@
             assert result == "a foo b"
             assert isinstance(result, cls)
 
+    def test_format_c_overflow(self):
+        raises(OverflowError, b'{0:c}'.format, -1)
+        raises(OverflowError, b'{0:c}'.format, 256)
+
     def test_split(self):
         assert "".split() == []
         assert "".split('x') == ['']
diff --git a/pypy/objspace/std/test/test_unicodeobject.py b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -947,6 +947,11 @@
         assert repr("%s" % u) == "u'__unicode__ overridden'"
         assert repr("{}".format(u)) == "'__unicode__ overridden'"
 
+    def test_format_c_overflow(self):
+        import sys
+        raises(OverflowError, u'{0:c}'.format, -1)
+        raises(OverflowError, u'{0:c}'.format, sys.maxunicode + 1)
+
     def test_replace_with_buffer(self):
         assert u'abc'.replace(buffer('b'), buffer('e')) == u'aec'
         assert u'abc'.replace(buffer('b'), u'e') == u'aec'


More information about the pypy-commit mailing list