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.TemporaryFile example in docs doesnt work
Type: Stage:
Components: Documentation, Library (Lib) Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rosslagerwall Nosy List: docs@python, eric.araujo, python-dev, rosslagerwall, schettino72
Priority: normal Keywords:

Created on 2011-04-10 07:10 by schettino72, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg133447 - (view) Author: eduardo (schettino72) Date: 2011-04-10 07:10
From the example:
 http://docs.python.org/py3k/library/tempfile.html#examples

The error message is weird... but I guess the problem is the default mode 'w+b'.


Python 3.3a0 (default:78a66c98288d, Apr  9 2011, 16:13:31) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tempfile
>>> fp = tempfile.TemporaryFile()
>>> fp.write('hello')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'str' does not support the buffer interface
>>> fp2 = tempfile.TemporaryFile('w+')
>>> fp2.write('hello')
5
>>>
msg133450 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-04-10 07:41
New changeset 87d89f767b23 by Ross Lagerwall in branch '3.2':
Issue #11818: Fix tempfile examples for Python 3.
http://hg.python.org/cpython/rev/87d89f767b23
msg133451 - (view) Author: Ross Lagerwall (rosslagerwall) (Python committer) Date: 2011-04-10 07:43
Fixed the examples for Python 3.

It writes and reads bytes now. Also fixed the old Python 2 print statement.
msg133526 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-04-11 15:06
May I ask why 3.1 was not fixed too?
msg133562 - (view) Author: Ross Lagerwall (rosslagerwall) (Python committer) Date: 2011-04-12 04:21
http://docs.python.org/release/3.1.3/library/tempfile.html doesn't to have an "Examples" section like 3.2 and 3.3.

It appears to have been introduced in b172d7537b99 with #5178.
msg133585 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-04-12 15:55
Alright, thanks for replying :)
History
Date User Action Args
2022-04-11 14:57:16adminsetgithub: 56027
2011-04-12 15:55:33eric.araujosetmessages: + msg133585
2011-04-12 04:21:51rosslagerwallsetmessages: + msg133562
2011-04-11 15:06:05eric.araujosetnosy: + eric.araujo
messages: + msg133526
2011-04-10 07:43:37rosslagerwallsetstatus: open -> closed

assignee: docs@python -> rosslagerwall
versions: + Python 3.3
nosy: + rosslagerwall

messages: + msg133451
resolution: fixed
2011-04-10 07:41:48python-devsetnosy: + python-dev
messages: + msg133450
2011-04-10 07:10:37schettino72create