New submission from Howard Waterfall <[email protected]>:
The documentation for tempfile.mkstemp() says:
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.
I don't believe this is correct. It should say:
returns a tuple containing an OS-level file descriptor and the absolute
pathname of that file, in that order.
I say this because this works:
file_descriptor, uri = tempfile.mkstemp()
open_file = os.fdopen(file_descriptor, 'w')
open_file.write("hello world")
print(uri)
but this raises an error:
open_file, uri = tempfile.mkstemp()
open_file.write("hello world")
print(uri)
Traceback (most recent call last):
File "test.py", line 78, in <module>
main()
File "test.py", line 74, in main
open_file.write("hello world")
AttributeError: 'int' object has no attribute 'write'
----------
assignee: docs@python
components: Documentation
messages: 365805
nosy: Howard Waterfall, docs@python
priority: normal
severity: normal
status: open
title: tempfile.mkstemp() | Documentation Error
type: behavior
versions: Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue40191>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com