From 810b94a36416cecf38205fd48e6a0a9eb3d2998c Mon Sep 17 00:00:00 2001 From: Ross Lagerwall Date: Sun, 10 Apr 2011 09:30:04 +0200 Subject: [PATCH] Issue #11818: Fix tempfile examples for Python 3. --- 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 index 1e0a31fdcf7..01092fc5ebf 100644 --- a/Doc/library/tempfile.rst +++ b/Doc/library/tempfile.rst @@ -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 diff --git a/Misc/NEWS b/Misc/NEWS index 23026db2a87..b5dc98b2388 100644 --- 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? =========================