Browse Source

Use context manager

master
Sylvain Corlay 9 years ago
parent
commit
efe1ac1a31
  1. 5
      setup.py

5
setup.py

@ -17,11 +17,8 @@ def has_flag(compiler, flagname):
""" """
import tempfile import tempfile
fd, fname = tempfile.mkstemp('.cpp', 'main', text=True) fd, fname = tempfile.mkstemp('.cpp', 'main', text=True)
f = os.fdopen(fd, 'w') with os.fdopen(fd, 'w') as f:
try:
f.write('int main (int argc, char **argv) { return 0; }') f.write('int main (int argc, char **argv) { return 0; }')
finally:
f.close()
try: try:
compiler.compile([fname], extra_postargs=[flagname]) compiler.compile([fname], extra_postargs=[flagname])
except setuptools.distutils.errors.CompileError: except setuptools.distutils.errors.CompileError:

Loading…
Cancel
Save