Skip to content

Commit 90534e7

Browse files
committed
asd
Signed-off-by: Sebastien Binet <binet@cern.ch>
1 parent d18aacd commit 90534e7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

stdlib/tempfile/testdata/test.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,29 @@
6161
except Exception as e:
6262
print("INVALID error caught: %s" % e)
6363

64+
def remove(fd, name):
65+
os.fdopen(fd).close()
66+
os.remove(name)
67+
6468
## mkstemp
6569
try:
6670
fd, tmp = tempfile.mkstemp()
67-
os.remove(tmp)
71+
remove(fd, tmp)
6872
print("mkstemp() [OK]")
6973
except Exception as e:
7074
print("could not create tmp dir w/ mkstemp(): %s" % e)
7175

7276
try:
7377
fd, tmp = tempfile.mkstemp(prefix="prefix-", suffix="-suffix")
74-
os.remove(tmp)
78+
remove(fd, tmp)
7579
print("mkstemp(prefix='prefix-', suffix='-suffix') [OK]")
7680
except Exception as e:
7781
print("could not create tmp dir w/ mkstemp(prefix='prefix-', suffix='-suffix'): %s" % e)
7882

7983
try:
8084
top = tempfile.mkdtemp(prefix="prefix-", suffix="-suffix")
8185
fd, tmp = tempfile.mkstemp(prefix="prefix-", suffix="-suffix", dir=top)
82-
os.rmdir(tmp)
86+
remove(fd, tmp)
8387
os.remove(top)
8488
print("mkstemp(prefix='prefix-', suffix='-suffix', dir=top) [OK]")
8589
except Exception as e:
@@ -96,7 +100,7 @@
96100
try:
97101
fd, tmp = tempfile.mkstemp(prefix=b"prefix-", suffix="-suffix")
98102
print("missing exception!")
99-
os.rmdir(tmp)
103+
remove(fd, tmp)
100104
except TypeError as e:
101105
print("caught: %s [OK]" % e)
102106
except Exception as e:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy