]> granicus.if.org Git - python/commitdiff
Issue #1054943: Fix unicodedata.normalize('NFC', text) for the Public Review
authorVictor Stinner <victor.stinner@haypocalc.com>
Thu, 4 Mar 2010 12:09:33 +0000 (12:09 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Thu, 4 Mar 2010 12:09:33 +0000 (12:09 +0000)
Issue #29.

PR #29 was released in february 2004!

Lib/test/test_unicodedata.py
Misc/NEWS
Modules/unicodedata.c

index c82e4afb1077ca0bcdd0eeb01b757bdc78bda3cc..6fbb6dd4509f90def76b5ee9a18add503f51d818 100644 (file)
@@ -186,6 +186,11 @@ class UnicodeFunctionsTest(UnicodeDatabaseTest):
         # The rest can be found in test_normalization.py
         # which requires an external file.
 
+    def test_pr29(self):
+        # http://www.unicode.org/review/pr-29.html
+        for text in (u"\u0b47\u0300\u0b3e", u"\u1100\u0300\u1161"):
+            self.assertEqual(self.db.normalize('NFC', text), text)
+
     def test_east_asian_width(self):
         eaw = self.db.east_asian_width
         self.assertRaises(TypeError, eaw, 'a')
index fb45e5a59c4ea50e1d6074b9d5013bd5f287aebe..107c9912762c2284d1c6c8da820aae5d0956163c 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -41,6 +41,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #1054943: Fix unicodedata.normalize('NFC', text) for the Public Review
+  Issue #29
+
 - Issue #7494: fix a crash in _lsprof (cProfile) after clearing the profiler,
   reset also the pointer to the current pointer context.
 
index 2eb1911299c150f2548afea43ca784db27e27ab5..0269175c1ec40372915197e1a70312d9b671e69f 100644 (file)
@@ -682,7 +682,7 @@ nfc_nfkc(PyObject *self, PyObject *input, int k)
       comb = 0;
       while (i1 < end) {
           int comb1 = _getrecord_ex(*i1)->combining;
-          if (comb1 && comb == comb1) {
+          if (comb && (comb1 == 0 || comb == comb1)) {
               /* Character is blocked. */
               i1++;
               continue;