[Python-checkins] [3.9] bpo-17852: Doc: Fix the tutorial about closing files (GH-23135) (GH-23527)

miss-islington webhook-mailer at python.org
Tue Dec 1 05:53:51 EST 2020

commit: 4a44f53aa85c9400471ab084bc8fd8169065fc41
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2020-12-01T02:53:42-08:00

[3.9] bpo-17852: Doc: Fix the tutorial about closing files (GH-23135) (GH-23527)

Co-authored-by: Inada Naoki <songofacandy at gmail.com>
(cherry picked from commit c8aaf71dde4888864c0c351e2f935f87652c3d54)

Co-authored-by: Volker-Weissmann <39418860+Volker-Weissmann at users.noreply.github.com>

M Doc/tutorial/inputoutput.rst

diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst
index 366a532e817af..4e27cff83ce59 100644
--- a/Doc/tutorial/inputoutput.rst
+++ b/Doc/tutorial/inputoutput.rst
@@ -329,11 +329,16 @@ equivalent :keyword:`try`\ -\ :keyword:`finally` blocks::
 If you're not using the :keyword:`with` keyword, then you should call
 ``f.close()`` to close the file and immediately free up any system
-resources used by it. If you don't explicitly close a file, Python's
-garbage collector will eventually destroy the object and close the
-open file for you, but the file may stay open for a while.  Another
-risk is that different Python implementations will do this clean-up at
-different times.
+resources used by it.
+.. warning::
+   Calling ``f.write()`` without using the :keyword:`!with` keyword or calling
+   ``f.close()`` **might** result in the arguments
+   of ``f.write()`` not being completely written to the disk, even if the
+   program exits successfully.
+   See also https://bugs.python.org/issue17852
 After a file object is closed, either by a :keyword:`with` statement
 or by calling ``f.close()``, attempts to use the file object will

More information about the Python-checkins mailing list