Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 99d2fbb commit a255a72Copy full SHA for a255a72
1 file changed
Lib/tempfile.py
@@ -128,6 +128,13 @@ class TemporaryFileWrapper:
128
In particular, it seeks to automatically remove the file when it is
129
no longer needed.
130
"""
131
+
132
+ # Cache the unlinker so we don't get spurious errors at shutdown
133
+ # when the module-level "os" in None'd out. Note that this must
134
+ # be referenced as self.unlink, because the name TemporaryFileWrapper
135
+ # may also get None'd out before __del__ is called.
136
+ unlink = os.unlink
137
138
def __init__(self, file, path):
139
self.file = file
140
self.path = path
@@ -137,7 +144,7 @@ def close(self):
144
if not self.close_called:
145
self.close_called = 1
146
self.file.close()
- os.unlink(self.path)
147
+ self.unlink(self.path)
141
148
142
149
def __del__(self):
143
150
self.close()
0 commit comments