From 22475597ce46edc2082994c227a9d0d77e2efda6 Mon Sep 17 00:00:00 2001 From: William Meehan Date: Fri, 10 Apr 2020 09:51:20 -0400 Subject: [PATCH 1/4] bpo-40243: Use numeric_changed for UCD.numeric 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 | 6 ++++++ Modules/unicodedata.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py index b552d2bd1754b3..366a03ea03ba16 100644 --- a/Lib/test/test_unicodedata.py +++ b/Lib/test/test_unicodedata.py @@ -205,6 +205,12 @@ def test_issue29456(self): self.assertEqual(self.db.normalize('NFC', u11a7_str_a), u11a7_str_b) self.assertEqual(self.db.normalize('NFC', u11c3_str_a), u11c3_str_b) + def test_issue40243(self): + # BENGALI CURRENCY NUMERATOR FOUR + u09f7 = '\u09f7' + self.assertEqual(self.db.numeric(u09f7), 0.25) + self.assertEqual(self.db.ucd_3_2_0.numeric(u09f7), 4.0) + def test_east_asian_width(self): eaw = self.db.east_asian_width self.assertRaises(TypeError, eaw, b'a') diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c index 1a9e1c0b667d39..149d36d43931a8 100644 --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -230,9 +230,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; } } From f5494ec8dddce56a1668c19cf83938d76951c471 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2020 14:29:53 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NEWS.d/next/Library/2020-04-10-14-29-53.bpo-40243.85HRib.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2020-04-10-14-29-53.bpo-40243.85HRib.rst 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 index 00000000000000..a00cd479f5648e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-04-10-14-29-53.bpo-40243.85HRib.rst @@ -0,0 +1 @@ +Use numeric_changed for unicodedata.UCD.numeric \ No newline at end of file From cd3416c968b1c2baf5816ca5dbfd42ae44e778cf Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 11 Feb 2026 22:15:02 +0200 Subject: [PATCH 3/4] Fix tests. --- Lib/test/test_unicodedata.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py index dab0f5ca988ba7..83b94f97c22c9d 100644 --- a/Lib/test/test_unicodedata.py +++ b/Lib/test/test_unicodedata.py @@ -182,10 +182,14 @@ def test_numeric(self): # 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 @@ -541,12 +545,6 @@ def test_issue29456(self): self.assertEqual(self.db.normalize('NFC', u11a7_str_a), u11a7_str_b) self.assertEqual(self.db.normalize('NFC', u11c3_str_a), u11c3_str_b) - def test_issue40243(self): - # BENGALI CURRENCY NUMERATOR FOUR - u09f7 = '\u09f7' - self.assertEqual(self.db.numeric(u09f7), 0.25) - self.assertEqual(self.db.ucd_3_2_0.numeric(u09f7), 4.0) - def test_east_asian_width(self): eaw = self.db.east_asian_width self.assertRaises(TypeError, eaw, b'a') @@ -863,9 +861,9 @@ def graphemes(*args): 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): From 12fe3c2a767d7a0a11f9e91b66d0021d15cd9a3c Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 11 Feb 2026 22:28:48 +0200 Subject: [PATCH 4/4] Update NEWS entry. --- .../next/Library/2020-04-10-14-29-53.bpo-40243.85HRib.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index a00cd479f5648e..1f48525cdbecd0 100644 --- 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 @@ -1 +1 @@ -Use numeric_changed for unicodedata.UCD.numeric \ No newline at end of file +Fix :meth:`!unicodedata.ucd_3_2_0.numeric` for non-decimal values.