]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-84424: Use numeric_changed for UCD.numeric (GH-19457)
authorWilliam Meehan <wmeehan@fb.com>
Wed, 11 Feb 2026 20:58:24 +0000 (15:58 -0500)
committerGitHub <noreply@github.com>
Wed, 11 Feb 2026 20:58:24 +0000 (20:58 +0000)
This was causing ucd_3_2_0.numeric() to pick up only decimal
changes between Unicode 3.2.0 and the current version.

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 a46ca034f3bfc9ab9d846f5eecc28bf88972e424..83b94f97c22c9dc500cd0bbea9ae5dda49cdc61a 100644 (file)
@@ -182,10 +182,14 @@ class BaseUnicodeFunctionsTest:
 
         # 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
@@ -857,9 +861,9 @@ class UnicodeFunctionsTest(unittest.TestCase, BaseUnicodeFunctionsTest):
 class Unicode_3_2_0_FunctionsTest(unittest.TestCase, BaseUnicodeFunctionsTest):
     db = unicodedata.ucd_3_2_0
     old = True
-    expectedchecksum = ('f4526159891a4b766dd48045646547178737ba09'
+    expectedchecksum = ('4154d8d1232837e255edf3cdcbb5ab184d71f4a4'
                         if quicktest else
-                        'f217b8688d7bdff31db4207e078a96702f091597')
+                        '3aabaf66823b21b3d305dad804a62f6f6387c93e')
 
 
 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 586ce8d36dd46f85ff3bbfbf545aa47ecedd799e..091e6bcb9f3f49b423b93196f95d583fdf64895b 100644 (file)
@@ -270,9 +270,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;
         }
     }