Issue 17271: NamedTemporaryFile expects bytes, not string in documentation for tempfile module (original) (raw)

Issue17271

Created on 2013-02-22 05:55 by jsf80238@gmail.com, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg182640 - (view) Author: Jason S Friedman (jsf80238@gmail.com) Date: 2013-02-22 05:55
Page is http://docs.python.org/3/library/tempfile.html#module-tempfile. The code in question currently reads: >>> f = NamedTemporaryFile(delete=False) >>> f <open file '', mode 'w+b' at 0x384698> >>> f.name '/var/folders/5q/5qTPn6xq2RaWqk+1Ytw3-U+++TI/-Tmp-/tmpG7V1Y0' >>> f.write("Hello World!\n") >>> f.close() >>> os.unlink(f.name) >>> os.path.exists(f.name) False It should read: >>> import os >>> from tempfile import NamedTemporaryFile >>> f = NamedTemporaryFile(delete=False) >>> f <tempfile._TemporaryFileWrapper object at 0x29bfc50> >>> f.name '/tmp/tmpdxd_85' >>> f.write("Hello World!\n".encode()) 13 >>> f.close() >>> os.unlink(f.name) >>> os.path.exists(f.name) False
msg182649 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-02-22 06:29
New changeset 82343bbf8868 by Ezio Melotti in branch '3.2': #17271: update example in tempfile docs. http://hg.python.org/cpython/rev/82343bbf8868 New changeset a9993d40821f by Ezio Melotti in branch '3.3': #17271: merge with 3.2. http://hg.python.org/cpython/rev/a9993d40821f New changeset fcc61327c86c by Ezio Melotti in branch 'default': #17271: merge with 3.3. http://hg.python.org/cpython/rev/fcc61327c86c
msg182650 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-02-22 06:30
Fixed, thanks for the report!
History
Date User Action Args
2022-04-11 14:57:42 admin set github: 61473
2013-02-22 06:30:18 ezio.melotti set status: open -> closedtype: enhancementassignee: docs@python -> ezio.melottiversions: + Python 3.3, Python 3.4nosy: + ezio.melottimessages: + resolution: fixedstage: resolved
2013-02-22 06:29:46 python-dev set nosy: + python-devmessages: +
2013-02-22 05:55:23 jsf80238@gmail.com create