Documentation
On tempfile.mkstemp's documentation you can read:
Unlike TemporaryFile(), the user of mkstemp() is responsible for deleting the temporary file when done with it.
mkstemp() returns a tuple containing an OS-level handle to an open file (as would be returned by os.open()) and the absolute pathname of that file, in that order.
After seeing the os.open I thought it would be enough to use os.close on the file handle - which is obviously not the case.
I would suggest to update the first paragraph to something like this:
Unlike TemporaryFile(), the user of mkstemp() is responsible for deleting the temporary file with e.g. os.remove when done with it.
In my perfect world, this paragraph would even briefly mention whether a os.close is necessary before a os.remove, but I am aware the documentation should be kept succint.
Linked PRs
Documentation
On tempfile.mkstemp's documentation you can read:
After seeing the
os.openI thought it would be enough to useos.closeon the file handle - which is obviously not the case.I would suggest to update the first paragraph to something like this:
In my perfect world, this paragraph would even briefly mention whether a
os.closeis necessary before aos.remove, but I am aware the documentation should be kept succint.Linked PRs
mkstempdocumentation #107033