summaryrefslogtreecommitdiffstats
path: root/Tools/scripts
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2022-03-27 18:46:22 (GMT)
committerGitHub <noreply@github.com>2022-03-27 18:46:22 (GMT)
commit785cc6770588de087d09e89a69110af2542be208 (patch)
tree51fa41cae45bce1fa7d3f9f463c2b30d0e9f6f94 /Tools/scripts
parentc12ba6b2ff7908c8970b978f149d51ecd3fb195c (diff)
downloadcpython-785cc6770588de087d09e89a69110af2542be208.zip
cpython-785cc6770588de087d09e89a69110af2542be208.tar.gz
cpython-785cc6770588de087d09e89a69110af2542be208.tar.bz2
bpo-46429: tweak deepfreeze output (#32107)
Diffstat (limited to 'Tools/scripts')
-rw-r--r--Tools/scripts/deepfreeze.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Tools/scripts/deepfreeze.py b/Tools/scripts/deepfreeze.py
index 1831c15..dfa4b3a 100644
--- a/Tools/scripts/deepfreeze.py
+++ b/Tools/scripts/deepfreeze.py
@@ -170,6 +170,8 @@ class Printer:
def generate_unicode(self, name: str, s: str) -> str:
if s in identifiers:
return f"&_Py_ID({s})"
+ if re.match(r'\A[A-Za-z0-9_]+\Z', s):
+ name = f"const_str_{s}"
kind, ascii = analyze_character_width(s)
if kind == PyUnicode_1BYTE_KIND:
datatype = "uint8_t"
@@ -326,6 +328,10 @@ class Printer:
def generate_int(self, name: str, i: int) -> str:
if -5 <= i <= 256:
return f"(PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS + {i}]"
+ if i >= 0:
+ name = f"const_int_{i}"
+ else:
+ name = f"const_int_negative_{abs(i)}"
if abs(i) < 2**15:
self._generate_int_for_bits(name, i, 2**15)
else: