Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 810b94a

Browse files
committed
Issue #11818: Fix tempfile examples for Python 3.
1 parent dbb677a commit 810b94a

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

Doc/library/tempfile.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,26 +242,26 @@ Here are some examples of typical usage of the :mod:`tempfile` module::
242242

243243
# create a temporary file and write some data to it
244244
>>> fp = tempfile.TemporaryFile()
245-
>>> fp.write('Hello world!')
245+
>>> fp.write(b'Hello world!')
246246
# read data from file
247247
>>> fp.seek(0)
248248
>>> fp.read()
249-
'Hello world!'
249+
b'Hello world!'
250250
# close the file, it will be removed
251251
>>> fp.close()
252252

253253
# create a temporary file using a context manager
254254
>>> with tempfile.TemporaryFile() as fp:
255-
... fp.write('Hello world!')
255+
... fp.write(b'Hello world!')
256256
... fp.seek(0)
257257
... fp.read()
258-
'Hello world!'
258+
b'Hello world!'
259259
>>>
260260
# file is now closed and removed
261261

262262
# create a temporary directory using the context manager
263263
>>> with tempfile.TemporaryDirectory() as tmpdirname:
264-
... print 'created temporary directory', tmpdirname
264+
... print('created temporary directory', tmpdirname)
265265
>>>
266266
# directory and contents have been removed
267267

Misc/NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,11 @@ Tests
257257
- Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
258258
to open door files.
259259

260+
Documentation
261+
-------------
262+
263+
- Issue #11818: Fix tempfile examples for Python 3.
264+
260265

261266
What's New in Python 3.2?
262267
=========================

0 commit comments

Comments
 (0)