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.mkstemp() documentation discrepancy
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: nbastin, otterley
Priority: normal Keywords:

Created on 2004-03-25 06:06 by otterley, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg20308 - (view) Author: Michael S. Fischer (otterley) Date: 2004-03-25 06:06
The documentation for tempfile.mkstemp() at 
http://www.python.org/doc/2.3.3/lib/module-
tempfile.html (as well as the ActivePython 
documentation that ships with the Windows 2.3 build) 
says:

"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."

However, whenever I use it, it returns a tuple containing 
an integer (presumably the file descriptor) and the 
absolute pathname of the tempfile.  No file handle is 
returned.  

Sure enough, the in-line documentation states:

"The return value is a pair (fd, name) where fd is the file 
descriptor returned by os.open, and name is the 
filename."

Could someone please correct this discrepancy?
msg20309 - (view) Author: Nick Bastin (nbastin) * (Python committer) Date: 2004-03-26 18:47
Logged In: YES 
user_id=430343

As noted in the os.open() documentation, it returns a
file descriptor, which seems to make the mkstemp()
documentation perfectly reasonable (and correct).
msg20310 - (view) Author: Michael S. Fischer (otterley) Date: 2004-03-27 02:32
Logged In: YES 
user_id=7820

The documentation could be a bit clearer.  When I think of a 
file descriptor in python, I think of a file-like object, i.e. that 
which is returned by open(), as opposed to os.open().  

It's unclear to me why mkstemp() returns an os-level file 
descriptor as opposed to a Python file-like object, but I 
suppose that's beside the point.

I'll close the bug, though, because the documentation is 
literally correct, and the team has more urgent priorities.
History
Date User Action Args
2022-04-11 14:56:03adminsetgithub: 40076
2004-03-25 06:06:23otterleycreate