[pypy-commit] pypy default: Test and fix

arigo pypy.commits at gmail.com
Mon Apr 29 04:29:07 EDT 2019


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r96555:4cbb314b4683
Date: 2019-04-29 10:28 +0200
http://bitbucket.org/pypy/pypy/changeset/4cbb314b4683/

Log:	Test and fix

diff --git a/pypy/objspace/std/formatting.py b/pypy/objspace/std/formatting.py
--- a/pypy/objspace/std/formatting.py
+++ b/pypy/objspace/std/formatting.py
@@ -473,7 +473,8 @@
                 n = space.int_w(w_value)
                 if do_unicode:
                     try:
-                        c = rutf8.unichr_as_utf8(r_uint(n))
+                        c = rutf8.unichr_as_utf8(r_uint(n),
+                                                 allow_surrogates=True)
                     except rutf8.OutOfRange:
                         raise oefmt(space.w_OverflowError,
                                     "unicode character code out of range")
diff --git a/pypy/objspace/std/test/test_stringformat.py b/pypy/objspace/std/test/test_stringformat.py
--- a/pypy/objspace/std/test/test_stringformat.py
+++ b/pypy/objspace/std/test/test_stringformat.py
@@ -236,6 +236,8 @@
         raises(TypeError, '%c'.__mod__, ("bla",))
         raises(TypeError, '%c'.__mod__, ("",))
         raises(TypeError, '%c'.__mod__, (['c'],))
+        surrogate = 0xd800
+        assert u'%c' % surrogate == u'\ud800'
 
     def test_broken_unicode(self):
         raises(UnicodeDecodeError, 'Názov: %s'.__mod__, u'Jerry')


More information about the pypy-commit mailing list