gh-96954: use a directed acyclic word graph for storing the unicodeda… · python/cpython@9573d14 · GitHub
Skip to content

Commit 9573d14

Browse files
cfbolzambveendebakptsweeneyde
authored
gh-96954: use a directed acyclic word graph for storing the unicodedata codepoint names (#97906)
Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com> Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
1 parent 0e9c364 commit 9573d14

8 files changed

Lines changed: 18134 additions & 30444 deletions

File tree

Lines changed: 121 additions & 0 deletions

Lib/test/test_unicodedata.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,26 @@ def test_name_inverse_lookup(self):
104104
if looked_name := self.db.name(char, None):
105105
self.assertEqual(self.db.lookup(looked_name), char)
106106

107+
def test_no_names_in_pua(self):
108+
puas = [*range(0xe000, 0xf8ff),
109+
*range(0xf0000, 0xfffff),
110+
*range(0x100000, 0x10ffff)]
111+
for i in puas:
112+
char = chr(i)
113+
self.assertRaises(ValueError, self.db.name, char)
114+
115+
def test_lookup_nonexistant(self):
116+
# just make sure that lookup can fail
117+
for nonexistant in [
118+
"LATIN SMLL LETR A",
119+
"OPEN HANDS SIGHS",
120+
"DREGS",
121+
"HANDBUG",
122+
"MODIFIER LETTER CYRILLIC SMALL QUESTION MARK",
123+
"???",
124+
]:
125+
self.assertRaises(KeyError, self.db.lookup, nonexistant)
126+
107127
def test_digit(self):
108128
self.assertEqual(self.db.digit('A', None), None)
109129
self.assertEqual(self.db.digit('9'), 9)

Makefile.pre.in

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,14 @@ check-abidump: all
13421342
regen-limited-abi: all
13431343
$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/stable_abi.py --generate-all $(srcdir)/Misc/stable_abi.toml
13441344

1345+
############################################################################
1346+
# Regenerate Unicode Data
1347+
1348+
.PHONY: regen-unicodedata
1349+
regen-unicodedata:
1350+
$(PYTHON_FOR_REGEN) Tools/unicode/makeunicodedata.py
1351+
1352+
13451353
############################################################################
13461354
# Regenerate all generated files
13471355

@@ -1350,7 +1358,7 @@ regen-limited-abi: all
13501358
regen-all: regen-cases regen-typeslots \
13511359
regen-token regen-ast regen-keyword regen-sre regen-frozen \
13521360
regen-pegen-metaparser regen-pegen regen-test-frozenmain \
1353-
regen-test-levenshtein regen-global-objects
1361+
regen-test-levenshtein regen-global-objects regen-unicodedata
13541362
@echo
13551363
@echo "Note: make regen-stdlib-module-names, make regen-limited-abi"
13561364
@echo "and make regen-configure should be run manually"
Lines changed: 5 additions & 0 deletions

0 commit comments

Comments
 (0)