Author: Matti Picus <[email protected]>
Branch: unicode-utf8-py3
Changeset: r95401:d54afa255930
Date: 2018-12-02 08:27 -0800
http://bitbucket.org/pypy/pypy/changeset/d54afa255930/

Log:    test, fix for unicode.center

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
@@ -262,6 +262,7 @@
         assert u'abc'.center(5, u'*') == u'*abc*'    # Python 2.4
         assert u'abc'.center(5, '*') == u'*abc*'     # Python 2.4
         raises(TypeError, u'abc'.center, 4, u'cba')
+        assert 'x'.center(2, u'\U0010FFFF') == u'x\U0010FFFF'
 
     def test_title(self):
         assert "brown fox".title() == "Brown Fox"
diff --git a/pypy/objspace/std/unicodeobject.py 
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -868,15 +868,14 @@
     @unwrap_spec(width=int, w_fillchar=WrappedDefault(u' '))
     def descr_center(self, space, width, w_fillchar):
         value = self._utf8
-        fillchar = self.convert_arg_to_w_unicode(space, w_fillchar)._utf8
-        if len(fillchar) != 1:
+        fillchar = space.utf8_w(w_fillchar)
+        if space.len_w(w_fillchar) != 1:
             raise oefmt(space.w_TypeError,
                         "center() argument 2 must be a single character")
 
         d = width - self._len()
         if d > 0:
             offset = d//2 + (d & width & 1)
-            fillchar = fillchar[0]
             centered = offset * fillchar + value + (d - offset) * fillchar
         else:
             centered = value
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to