|
45 | 45 | from ..support import seven
|
46 | 46 |
|
47 | 47 |
|
| 48 | +class OnDiskTempFile: |
| 49 | + def __init__(self): |
| 50 | + self.path = None |
| 51 | + |
| 52 | + def __enter__(self): |
| 53 | + fd, path = tempfile.mkstemp() |
| 54 | + os.close(fd) |
| 55 | + self.path = path |
| 56 | + return self |
| 57 | + |
| 58 | + def __exit__(self, exc_type, exc_val, exc_tb): |
| 59 | + if os.path.exists(self.path): |
| 60 | + os.remove(self.path) |
| 61 | + |
| 62 | + |
48 | 63 | def is_exe(fpath):
|
49 | 64 | """Returns true if fpath is an executable."""
|
50 | 65 | if fpath is None:
|
@@ -780,8 +795,8 @@ def canRunLibcxxTests():
|
780 | 795 | return True, "libc++ always present"
|
781 | 796 |
|
782 | 797 | if platform == "linux":
|
783 |
| - with tempfile.NamedTemporaryFile() as f: |
784 |
| - cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", f.name, "-"] |
| 798 | + with OnDiskTempFile() as f: |
| 799 | + cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", f.path, "-"] |
785 | 800 | p = subprocess.Popen(
|
786 | 801 | cmd,
|
787 | 802 | stdin=subprocess.PIPE,
|
@@ -840,8 +855,8 @@ def canRunMsvcStlTests():
|
840 | 855 | if platform != "windows":
|
841 | 856 | return False, f"Don't know how to build with MSVC's STL on {platform}"
|
842 | 857 |
|
843 |
| - with tempfile.NamedTemporaryFile() as f: |
844 |
| - cmd = [configuration.compiler, "-xc++", "-o", f.name, "-E", "-"] |
| 858 | + with OnDiskTempFile() as f: |
| 859 | + cmd = [configuration.compiler, "-xc++", "-o", f.path, "-E", "-"] |
845 | 860 | p = subprocess.Popen(
|
846 | 861 | cmd,
|
847 | 862 | stdin=subprocess.PIPE,
|
|
0 commit comments