summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-05-17 21:48:35 (GMT)
committerGitHub <noreply@github.com>2021-05-17 21:48:35 (GMT)
commiteaede0ded72e67cee4a91c086847d54cb64ca74c (patch)
tree3c9bf4c33572db77fc79ae6a701628614c94f3a6 /Tools
parentf32c7950e0077b6d9a8e217c2796fc582f18ca08 (diff)
downloadcpython-eaede0ded72e67cee4a91c086847d54cb64ca74c.zip
cpython-eaede0ded72e67cee4a91c086847d54cb64ca74c.tar.gz
cpython-eaede0ded72e67cee4a91c086847d54cb64ca74c.tar.bz2
bpo-44131: Test Py_FrozenMain() (GH-26126)
* Add test_frozenmain to test_embed * Add Programs/test_frozenmain.py * Add Programs/freeze_test_frozenmain.py * Add Programs/test_frozenmain.h * Add make regen-test-frozenmain * Add test_frozenmain command to Programs/_testembed * _testembed.c: add error(msg) function
Diffstat (limited to 'Tools')
-rw-r--r--Tools/freeze/makefreeze.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/Tools/freeze/makefreeze.py b/Tools/freeze/makefreeze.py
index 64e3e6b..d7d05db 100644
--- a/Tools/freeze/makefreeze.py
+++ b/Tools/freeze/makefreeze.py
@@ -74,14 +74,12 @@ def makefreeze(base, dict, debug=0, entry_point=None, fail_import=()):
# Write a C initializer for a module containing the frozen python code.
# The array is called M_<mod>.
-def writecode(outfp, mod, str):
- outfp.write('unsigned char M_%s[] = {' % mod)
- for i in range(0, len(str), 16):
- outfp.write('\n\t')
- for c in bytes(str[i:i+16]):
- outfp.write('%d,' % c)
- outfp.write('\n};\n')
-
-## def writecode(outfp, mod, str):
-## outfp.write('unsigned char M_%s[%d] = "%s";\n' % (mod, len(str),
-## '\\"'.join(map(lambda s: repr(s)[1:-1], str.split('"')))))
+def writecode(fp, mod, data):
+ print('unsigned char M_%s[] = {' % mod, file=fp)
+ indent = ' ' * 4
+ for i in range(0, len(data), 16):
+ print(indent, file=fp, end='')
+ for c in bytes(data[i:i+16]):
+ print('%d,' % c, file=fp, end='')
+ print('', file=fp)
+ print('};', file=fp)