[New-bugs-announce] [issue37865] tempfile.NamedTemporaryFile() raises exception on close() when file is absent

Andrei Pashkin report at bugs.python.org
Thu Aug 15 03:43:15 EDT 2019


New submission from Andrei Pashkin <andrew.pashkin at gmx.co.uk>:

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'

----------
messages: 349794
nosy: pashkin
priority: normal
severity: normal
status: open
title: tempfile.NamedTemporaryFile() raises exception on close() when file is absent
versions: Python 3.6, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37865>
_______________________________________


More information about the New-bugs-announce mailing list