Skip to content

Commit

Permalink
gh-103875: Use ascii and latin1 singletons in deepfreeze (#103876)
Browse files Browse the repository at this point in the history
  • Loading branch information
oraluben authored Apr 26, 2023
1 parent 438b811 commit 214e568
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Tools/build/deepfreeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ def generate_unicode(self, name: str, s: str) -> str:
return f"&_Py_STR({strings[s]})"
if s in identifiers:
return f"&_Py_ID({s})"
if len(s) == 1:
c = ord(s)
if c < 128:
return f"(PyObject *)&_Py_SINGLETON(strings).ascii[{c}]"
elif c < 256:
return f"(PyObject *)&_Py_SINGLETON(strings).latin1[{c - 128}]"
if re.match(r'\A[A-Za-z0-9_]+\Z', s):
name = f"const_str_{s}"
kind, ascii = analyze_character_width(s)
Expand Down

0 comments on commit 214e568

Please sign in to comment.