]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-84424: Use numeric_changed for UCD.numeric (GH-19457) (GH-144732)
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 12 Feb 2026 08:35:09 +0000 (10:35 +0200)
committerGitHub <noreply@github.com>
Thu, 12 Feb 2026 08:35:09 +0000 (08:35 +0000)
This was causing ucd_3_2_0.numeric() to pick up only decimal
changes between Unicode 3.2.0 and the current version.
(cherry picked from commit 3e0322ff16f47caa3e273d453f007d3918b8ac80)

Co-authored-by: William Meehan <wmeehan@fb.com>
Lib/test/test_unicodedata.py
Misc/NEWS.d/next/Library/2020-04-10-14-29-53.bpo-40243.85HRib.rst [new file with mode: 0644]
Modules/unicodedata.c

index a0cff2bc65cc39d9673962ba7b9a105583e86d83..725a538e15dd956e3e3cee93bb403e56061b48fe 100644 (file)
@@ -170,10 +170,14 @@ class UnicodeFunctionsTest(unittest.TestCase):
 
         # New in 4.1.0
         self.assertEqual(self.db.numeric('\U0001012A', None), None if self.old else 9000)
+        # Changed in 4.1.0
+        self.assertEqual(self.db.numeric('\u5793', None), 1e20 if self.old else None)
         # New in 5.0.0
         self.assertEqual(self.db.numeric('\u07c0', None), None if self.old else 0.0)
         # New in 5.1.0
         self.assertEqual(self.db.numeric('\ua627', None), None if self.old else 7.0)
+        # Changed in 5.2.0
+        self.assertEqual(self.db.numeric('\u09f6'), 3.0 if self.old else 3/16)
         # New in 6.0.0
         self.assertEqual(self.db.numeric('\u0b72', None), None if self.old else 0.25)
         # New in 12.0.0
@@ -569,9 +573,9 @@ class UnicodeFunctionsTest(unittest.TestCase):
 class Unicode_3_2_0_FunctionsTest(UnicodeFunctionsTest):
     db = unicodedata.ucd_3_2_0
     old = True
-    expectedchecksum = ('76b126d719d52ba11788a627d058163106da7d56'
+    expectedchecksum = ('4154d8d1232837e255edf3cdcbb5ab184d71f4a4'
                         if quicktest else
-                        '871389bdd96a709929496da7f9e59718daf61adb')
+                        'b678d38ffbf1f1de092b2af1ed155602909fcd8d')
 
 
 class UnicodeMiscTest(unittest.TestCase):
diff --git a/Misc/NEWS.d/next/Library/2020-04-10-14-29-53.bpo-40243.85HRib.rst b/Misc/NEWS.d/next/Library/2020-04-10-14-29-53.bpo-40243.85HRib.rst
new file mode 100644 (file)
index 0000000..1f48525
--- /dev/null
@@ -0,0 +1 @@
+Fix :meth:`!unicodedata.ucd_3_2_0.numeric` for non-decimal values.
index 333ffe68a454e4995de698aeb950cf57dc912c93..06568581afc6a6a8a5ee0467cae50add2aff02a0 100644 (file)
@@ -228,9 +228,9 @@ unicodedata_UCD_numeric_impl(PyObject *self, int chr,
             have_old = 1;
             rc = -1.0;
         }
-        else if (old->decimal_changed != 0xFF) {
+        else if (old->numeric_changed != 0.0) {
             have_old = 1;
-            rc = old->decimal_changed;
+            rc = old->numeric_changed;
         }
     }