This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: tempfile.NamedTemporaryFile() raises exception on close() when file is absent
Type: Stage: resolved
Components: Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: NamedTemporaryFile with delete=True should not fail if file already deleted
View: 29573
Assigned To: Nosy List: pashkin, xtreak
Priority: normal Keywords:

Created on 2019-08-15 07:43 by pashkin, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg349794 - (view) Author: Andrei Pashkin (pashkin) Date: 2019-08-15 07:43
Here is an example:

import tempfile
import os


with tempfile.NamedTemporaryFile() as temp:
    os.remove(temp.name)


And here is an error it produces:

Traceback (most recent call last):
  File "test.py", line 6, in <module>
    os.remove(temp.name)
  File "/usr/lib/python3.7/tempfile.py", line 639, in __exit__
    self.close()
  File "/usr/lib/python3.7/tempfile.py", line 646, in close
    self._closer.close()
  File "/usr/lib/python3.7/tempfile.py", line 583, in close
    unlink(self.name)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpzn8gtiz1'
msg349795 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-08-15 07:52
I think this is same as https://bugs.python.org/issue29573 .
History
Date User Action Args
2022-04-11 14:59:19adminsetgithub: 82046
2020-11-25 18:37:33iritkatrielsetstatus: open -> closed
superseder: NamedTemporaryFile with delete=True should not fail if file already deleted
resolution: duplicate
stage: resolved
2019-08-15 07:52:29xtreaksetnosy: + xtreak
messages: + msg349795
2019-08-15 07:43:15pashkincreate