mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Issue #22826: The result of open() in Tools/freeze/bkfile.py is now better
compatible with regular files (in particular it now supports the context management protocol).
This commit is contained in:
parent
8490f5acfe
commit
53c3fb186a
4 changed files with 59 additions and 87 deletions
|
@ -439,25 +439,17 @@ def main():
|
|||
frozendllmain_c, os.path.basename(extensions_c)] + files
|
||||
maindefn = checkextensions_win32.CExtension( '__main__', xtras )
|
||||
frozen_extensions.append( maindefn )
|
||||
outfp = open(makefile, 'w')
|
||||
try:
|
||||
with open(makefile, 'w') as outfp:
|
||||
winmakemakefile.makemakefile(outfp,
|
||||
locals(),
|
||||
frozen_extensions,
|
||||
os.path.basename(target))
|
||||
finally:
|
||||
outfp.close()
|
||||
return
|
||||
|
||||
# generate config.c and Makefile
|
||||
builtins.sort()
|
||||
infp = open(config_c_in)
|
||||
outfp = bkfile.open(config_c, 'w')
|
||||
try:
|
||||
with open(config_c_in) as infp, bkfile.open(config_c, 'w') as outfp:
|
||||
makeconfig.makeconfig(infp, outfp, builtins)
|
||||
finally:
|
||||
outfp.close()
|
||||
infp.close()
|
||||
|
||||
cflags = ['$(OPT)']
|
||||
cppflags = defines + includes
|
||||
|
@ -475,11 +467,8 @@ def main():
|
|||
files + supp_sources + addfiles + libs + \
|
||||
['$(MODLIBS)', '$(LIBS)', '$(SYSLIBS)']
|
||||
|
||||
outfp = bkfile.open(makefile, 'w')
|
||||
try:
|
||||
with bkfile.open(makefile, 'w') as outfp:
|
||||
makemakefile.makemakefile(outfp, somevars, files, base_target)
|
||||
finally:
|
||||
outfp.close()
|
||||
|
||||
# Done!
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue