File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 61
61
except Exception as e :
62
62
print ("INVALID error caught: %s" % e )
63
63
64
+ def remove (fd , name ):
65
+ os .fdopen (fd ).close ()
66
+ os .remove (name )
67
+
64
68
## mkstemp
65
69
try :
66
70
fd , tmp = tempfile .mkstemp ()
67
- os . remove (tmp )
71
+ remove (fd , tmp )
68
72
print ("mkstemp() [OK]" )
69
73
except Exception as e :
70
74
print ("could not create tmp dir w/ mkstemp(): %s" % e )
71
75
72
76
try :
73
77
fd , tmp = tempfile .mkstemp (prefix = "prefix-" , suffix = "-suffix" )
74
- os . remove (tmp )
78
+ remove (fd , tmp )
75
79
print ("mkstemp(prefix='prefix-', suffix='-suffix') [OK]" )
76
80
except Exception as e :
77
81
print ("could not create tmp dir w/ mkstemp(prefix='prefix-', suffix='-suffix'): %s" % e )
78
82
79
83
try :
80
84
top = tempfile .mkdtemp (prefix = "prefix-" , suffix = "-suffix" )
81
85
fd , tmp = tempfile .mkstemp (prefix = "prefix-" , suffix = "-suffix" , dir = top )
82
- os . rmdir ( tmp )
86
+ remove ( fd , tmp )
83
87
os .remove (top )
84
88
print ("mkstemp(prefix='prefix-', suffix='-suffix', dir=top) [OK]" )
85
89
except Exception as e :
96
100
try :
97
101
fd , tmp = tempfile .mkstemp (prefix = b"prefix-" , suffix = "-suffix" )
98
102
print ("missing exception!" )
99
- os . rmdir ( tmp )
103
+ remove ( fd , tmp )
100
104
except TypeError as e :
101
105
print ("caught: %s [OK]" % e )
102
106
except Exception as e :
You can’t perform that action at this time.
0 commit comments