mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
packaging: use with open() instead of try/finally: close
This commit is contained in:
parent
0e3f3a7076
commit
21a9c748aa
11 changed files with 41 additions and 69 deletions
|
@ -728,8 +728,7 @@ class CCompiler:
|
|||
if library_dirs is None:
|
||||
library_dirs = []
|
||||
fd, fname = tempfile.mkstemp(".c", funcname, text=True)
|
||||
f = os.fdopen(fd, "w")
|
||||
try:
|
||||
with os.fdopen(fd, "w") as f:
|
||||
for incl in includes:
|
||||
f.write("""#include "%s"\n""" % incl)
|
||||
f.write("""\
|
||||
|
@ -737,8 +736,6 @@ main (int argc, char **argv) {
|
|||
%s();
|
||||
}
|
||||
""" % funcname)
|
||||
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