From: Alexander Belopolsky Date: Tue, 28 Dec 2010 16:15:08 +0000 (+0000) Subject: Merged revisions 87541,87543 via svnmerge from X-Git-Tag: v2.6.7~23 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=893c354a556fa3731644d6698d47c1112bd4b45a;p=python Merged revisions 87541,87543 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/release27-maint ................ r87541 | alexander.belopolsky | 2010-12-28 10:47:56 -0500 (Tue, 28 Dec 2010) | 9 lines Merged revisions 87442 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r87442 | alexander.belopolsky | 2010-12-22 21:27:37 -0500 (Wed, 22 Dec 2010) | 1 line Issue #10254: Fixed a crash and a regression introduced by the implementation of PRI 29. ........ ................ r87543 | alexander.belopolsky | 2010-12-28 11:04:06 -0500 (Tue, 28 Dec 2010) | 1 line fixed issue 10254 test ................ --- diff --git a/Lib/test/test_normalization.py b/Lib/test/test_normalization.py index e4da01fe4c..4a0f1c5005 100644 --- a/Lib/test/test_normalization.py +++ b/Lib/test/test_normalization.py @@ -49,9 +49,6 @@ class NormalizationTest(unittest.TestCase): if line.startswith("@Part"): part = line.split()[0] continue - if part == "@Part3": - # XXX we don't support PRI #29 yet, so skip these tests for now - continue try: c1,c2,c3,c4,c5 = [unistr(x) for x in line.split(';')[:-1]] except RangeError: diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py index 61a10318bb..509628bb2f 100644 --- a/Lib/test/test_unicodedata.py +++ b/Lib/test/test_unicodedata.py @@ -187,9 +187,22 @@ class UnicodeFunctionsTest(UnicodeDatabaseTest): def test_pr29(self): # http://www.unicode.org/review/pr-29.html - for text in (u"\u0b47\u0300\u0b3e", u"\u1100\u0300\u1161"): + # See issues #1054943 and #10254. + composed = (u"\u0b47\u0300\u0b3e", u"\u1100\u0300\u1161", + u'Li\u030dt-s\u1e73\u0301', + u'\u092e\u093e\u0930\u094d\u0915 \u091c\u093c' + + u'\u0941\u0915\u0947\u0930\u092c\u0930\u094d\u0917', + u'\u0915\u093f\u0930\u094d\u0917\u093f\u091c\u093c' + + 'u\u0938\u094d\u0924\u093e\u0928') + for text in composed: self.assertEqual(self.db.normalize('NFC', text), text) + def test_issue10254(self): + # Crash reported in #10254 + a = u'C\u0338' * 20 + u'C\u0327' + b = u'C\u0338' * 20 + u'\xC7' + self.assertEqual(self.db.normalize('NFC', a), b) + def test_east_asian_width(self): eaw = self.db.east_asian_width self.assertRaises(TypeError, eaw, 'a') diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c index 8291d58e8f..03b869093a 100644 --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -681,10 +681,14 @@ nfc_nfkc(PyObject *self, PyObject *input, int k) comb = 0; while (i1 < end) { int comb1 = _getrecord_ex(*i1)->combining; - if (comb && (comb1 == 0 || comb == comb1)) { - /* Character is blocked. */ - i1++; - continue; + if (comb) { + if (comb1 == 0) + break; + if (comb >= comb1) { + /* Character is blocked. */ + i1++; + continue; + } } l = find_nfc_index(self, nfc_last, *i1); /* *i1 cannot be combined with *i. If *i1 @@ -708,6 +712,7 @@ nfc_nfkc(PyObject *self, PyObject *input, int k) /* Replace the original character. */ *i = code; /* Mark the second character unused. */ + assert(cskipped < 20); skipped[cskipped++] = i1; i1++; f = find_nfc_index(self, nfc_first, *i);