[pypy-commit] pypy py3.6: fix corner case in unicode.title
cfbolz
pypy.commits at gmail.com
Mon Feb 25 07:04:56 EST 2019
Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch: py3.6
Changeset: r96163:fd6330354b33
Date: 2019-02-25 13:02 +0100
http://bitbucket.org/pypy/pypy/changeset/fd6330354b33/
Log: fix corner case in unicode.title
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
@@ -1,12 +1,11 @@
# -*- encoding: utf-8 -*-
import py
-import sys
try:
from hypothesis import given, strategies, settings, example
HAS_HYPOTHESIS = True
except ImportError:
HAS_HYPOTHESIS = False
-
+
from rpython.rlib import rutf8
from pypy.interpreter.error import OperationError
@@ -356,6 +355,9 @@
assert (chr(0x345) + u'abc').title() == u'\u0399abc'
assert (chr(0x345) + u'ABC').title() == u'\u0399abc'
+ def test_title_bug(self):
+ assert (chr(496) + "abc").title() == 'J̌abc'
+
def test_istitle(self):
assert u"".istitle() == False
assert u"!".istitle() == False
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
@@ -431,7 +431,7 @@
codes = unicodedb.tolower_full(ch)
for c in codes:
builder.append_code(c)
- previous_is_cased = unicodedb.iscased(codes[-1])
+ previous_is_cased = unicodedb.iscased(ch)
i += 1
return self.from_utf8builder(builder)
More information about the pypy-commit
mailing list