]> granicus.if.org Git - python/commitdiff
Issue #11818: Fix tempfile examples for Python 3.
authorRoss Lagerwall <rosslagerwall@gmail.com>
Sun, 10 Apr 2011 07:30:04 +0000 (09:30 +0200)
committerRoss Lagerwall <rosslagerwall@gmail.com>
Sun, 10 Apr 2011 07:30:04 +0000 (09:30 +0200)
Doc/library/tempfile.rst
Misc/NEWS

index 1e0a31fdcf7a3c865b6c26f217a9aed6de50244a..01092fc5ebfaab9043a8e0681ebb2444ca6a65af 100644 (file)
@@ -242,26 +242,26 @@ Here are some examples of typical usage of the :mod:`tempfile` module::
 
     # 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
 
index 23026db2a87f13a265bc6820b0ae8bcccb159b5f..b5dc98b23883f11ac8af9577b67ae63577c0c611 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -257,6 +257,11 @@ Tests
 - 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?
 =========================