[Python-checkins] cpython (3.2): Issue #11818: Fix tempfile examples for Python 3.

ross.lagerwall python-checkins at python.org
Sun Apr 10 09:41:47 CEST 2011


http://hg.python.org/cpython/rev/87d89f767b23
changeset: 69232:87d89f767b23
branch: 3.2
parent: 69229:35f4e0d1d64b
user: Ross Lagerwall <rosslagerwall at gmail.com>
date: Sun Apr 10 09:30:04 2011 +0200
summary:
 Issue #11818: Fix tempfile examples for Python 3.
files:
 Doc/library/tempfile.rst | 10 +++++-----
 Misc/NEWS | 5 +++++
 2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst
--- a/Doc/library/tempfile.rst
+++ b/Doc/library/tempfile.rst
@@ -242,26 +242,26 @@
 
 # create a temporary file and write some data to it
 >>> fp = tempfile.TemporaryFile()
- >>> fp.write('Hello world!')
+ >>> fp.write(b'Hello world!')
 # read data from file
 >>> fp.seek(0)
 >>> fp.read()
- 'Hello world!'
+ b'Hello world!'
 # close the file, it will be removed
 >>> fp.close()
 
 # create a temporary file using a context manager
 >>> with tempfile.TemporaryFile() as fp:
- ... fp.write('Hello world!')
+ ... fp.write(b'Hello world!')
 ... fp.seek(0)
 ... fp.read()
- 'Hello world!'
+ b'Hello world!'
 >>>
 # file is now closed and removed
 
 # create a temporary directory using the context manager
 >>> with tempfile.TemporaryDirectory() as tmpdirname:
- ... print 'created temporary directory', tmpdirname
+ ... print('created temporary directory', tmpdirname)
 >>>
 # directory and contents have been removed
 
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -257,6 +257,11 @@
 - Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
 to open door files.
 
+Documentation
+-------------
+
+- Issue #11818: Fix tempfile examples for Python 3.
+
 
 What's New in Python 3.2?
 =========================
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /