From c22010e6d2233e9b72cfc0242df327d3ebc3d5be Mon Sep 17 00:00:00 2001 From: Krzysiek Karbowiak Date: Tue, 24 Oct 2023 15:48:00 +0200 Subject: [PATCH 1/4] Fix NamedTemporaryFile example code --- Doc/library/tempfile.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst index b2baa54d9522df..68294bc1288469 100644 --- a/Doc/library/tempfile.rst +++ b/Doc/library/tempfile.rst @@ -404,12 +404,12 @@ Here are some examples of typical usage of the :mod:`tempfile` module:: # create a temporary file using a context manager # close the file, use the name to open the file again - >>> with tempfile.TemporaryFile(delete_on_close=False) as fp: + >>> with tempfile.NamedTemporaryFile(delete_on_close=False) as fp: ... fp.write(b'Hello world!') ... fp.close() # the file is closed, but not removed # open the file again by using its name - ... with open(fp.name) as f + ... with open(fp.name) as f: ... f.read() b'Hello world!' >>> From 86b6d4600028300bfaea715ea5a30b15fdc112e9 Mon Sep 17 00:00:00 2001 From: Krzysiek Karbowiak Date: Tue, 24 Oct 2023 21:46:58 +0200 Subject: [PATCH 2/4] Fix indentation --- Doc/library/tempfile.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst index 68294bc1288469..584f76be1e795b 100644 --- a/Doc/library/tempfile.rst +++ b/Doc/library/tempfile.rst @@ -405,12 +405,12 @@ Here are some examples of typical usage of the :mod:`tempfile` module:: # create a temporary file using a context manager # close the file, use the name to open the file again >>> with tempfile.NamedTemporaryFile(delete_on_close=False) as fp: - ... fp.write(b'Hello world!') - ... fp.close() + ... fp.write(b'Hello world!') + ... fp.close() # the file is closed, but not removed # open the file again by using its name - ... with open(fp.name) as f: - ... f.read() + ... with open(fp.name) as f: + ... f.read() b'Hello world!' >>> # file is now removed From 8f8886e17c84ffd316f4e15402477bd8453163be Mon Sep 17 00:00:00 2001 From: Krzysiek Karbowiak Date: Tue, 24 Oct 2023 22:02:23 +0200 Subject: [PATCH 3/4] Fix comments indentation --- Doc/library/tempfile.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst index 584f76be1e795b..8cf2c356b7e9f1 100644 --- a/Doc/library/tempfile.rst +++ b/Doc/library/tempfile.rst @@ -407,8 +407,8 @@ Here are some examples of typical usage of the :mod:`tempfile` module:: >>> with tempfile.NamedTemporaryFile(delete_on_close=False) as fp: ... fp.write(b'Hello world!') ... fp.close() - # the file is closed, but not removed - # open the file again by using its name + ... # the file is closed, but not removed + ... # open the file again by using its name ... with open(fp.name) as f: ... f.read() b'Hello world!' From 0b9892390e4f508d6a44ec2bb4baed5adc918a75 Mon Sep 17 00:00:00 2001 From: Krzysiek Karbowiak Date: Tue, 31 Oct 2023 22:09:11 +0100 Subject: [PATCH 4/4] Fix open mode --- Doc/library/tempfile.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst index 8cf2c356b7e9f1..b68a78e8267bcc 100644 --- a/Doc/library/tempfile.rst +++ b/Doc/library/tempfile.rst @@ -409,7 +409,7 @@ Here are some examples of typical usage of the :mod:`tempfile` module:: ... fp.close() ... # the file is closed, but not removed ... # open the file again by using its name - ... with open(fp.name) as f: + ... with open(fp.name, mode='rb') as f: ... f.read() b'Hello world!' >>>