mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-27 23:40:10 +00:00
Use tempfile.TemporaryDirectory in conform/glibcconform.py.
Now that we require Python 3.4 or later, Python code creating temporary directories can use tempfile.TemporaryDirectory in "with" to have the directory deleted automatically instead of needing to use try/finally to handle removing a directory created with tempfile.mkdtemp. This patch does so in conform/glibcconform.py. Tested for x86_64. * conform/glibcconform.py: Do not import shutil. (list_exported_functions): Use tempfile.TemporaryDirectory instead of mkdtemp.
This commit is contained in:
parent
c6982f7efc
commit
954cf3c29b
@ -1,5 +1,9 @@
|
|||||||
2018-10-29 Joseph Myers <joseph@codesourcery.com>
|
2018-10-29 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
|
* conform/glibcconform.py: Do not import shutil.
|
||||||
|
(list_exported_functions): Use tempfile.TemporaryDirectory instead
|
||||||
|
of mkdtemp.
|
||||||
|
|
||||||
* configure.ac (PYTHON_PROG): Use AC_CHECK_PROG_VER. Set
|
* configure.ac (PYTHON_PROG): Use AC_CHECK_PROG_VER. Set
|
||||||
critic_missing for versions before 3.4.
|
critic_missing for versions before 3.4.
|
||||||
* configure: Regenerated.
|
* configure: Regenerated.
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
import shutil
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
@ -43,11 +42,9 @@ def list_exported_functions(cc, standard, header):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
cc_all = '%s -D_ISOMAC %s' % (cc, CFLAGS[standard])
|
cc_all = '%s -D_ISOMAC %s' % (cc, CFLAGS[standard])
|
||||||
# tempfile.TemporaryDirectory requires Python 3.2, so use mkdtemp.
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
temp_dir = tempfile.mkdtemp()
|
c_file_name = os.path.join(temp_dir, 'test.c')
|
||||||
c_file_name = os.path.join(temp_dir, 'test.c')
|
aux_file_name = os.path.join(temp_dir, 'test.c.aux')
|
||||||
aux_file_name = os.path.join(temp_dir, 'test.c.aux')
|
|
||||||
try:
|
|
||||||
with open(c_file_name, 'w') as c_file:
|
with open(c_file_name, 'w') as c_file:
|
||||||
c_file.write('#include <%s>\n' % header)
|
c_file.write('#include <%s>\n' % header)
|
||||||
fns = set()
|
fns = set()
|
||||||
@ -72,6 +69,4 @@ def list_exported_functions(cc, standard, header):
|
|||||||
else:
|
else:
|
||||||
raise ValueError("couldn't parse -aux-info output: %s"
|
raise ValueError("couldn't parse -aux-info output: %s"
|
||||||
% line)
|
% line)
|
||||||
finally:
|
|
||||||
shutil.rmtree(temp_dir)
|
|
||||||
return fns
|
return fns
|
||||||
|
Loading…
Reference in New Issue
Block a user