mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
Always close files in distutils code and tests (#10252).
This commit is contained in:
parent
afb078dd26
commit
bee5cef7db
24 changed files with 261 additions and 171 deletions
|
@ -779,14 +779,16 @@ class CCompiler:
|
|||
library_dirs = []
|
||||
fd, fname = tempfile.mkstemp(".c", funcname, text=True)
|
||||
f = os.fdopen(fd, "w")
|
||||
for incl in includes:
|
||||
f.write("""#include "%s"\n""" % incl)
|
||||
f.write("""\
|
||||
try:
|
||||
for incl in includes:
|
||||
f.write("""#include "%s"\n""" % incl)
|
||||
f.write("""\
|
||||
main (int argc, char **argv) {
|
||||
%s();
|
||||
}
|
||||
""" % funcname)
|
||||
f.close()
|
||||
finally:
|
||||
f.close()
|
||||
try:
|
||||
objects = self.compile([fname], include_dirs=include_dirs)
|
||||
except CompileError:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue