File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -329,11 +329,16 @@ equivalent :keyword:`try`\ -\ :keyword:`finally` blocks::
329
329
330
330
If you're not using the :keyword: `with ` keyword, then you should call
331
331
``f.close() `` to close the file and immediately free up any system
332
- resources used by it. If you don't explicitly close a file, Python's
333
- garbage collector will eventually destroy the object and close the
334
- open file for you, but the file may stay open for a while. Another
335
- risk is that different Python implementations will do this clean-up at
336
- different times.
332
+ resources used by it.
333
+
334
+ .. warning ::
335
+ Calling ``f.write() `` without using the :keyword: `!with ` keyword or calling
336
+ ``f.close() `` **might ** result in the arguments
337
+ of ``f.write() `` not being completely written to the disk, even if the
338
+ program exits successfully.
339
+
340
+ ..
341
+ See also https://bugs.python.org/issue17852
337
342
338
343
After a file object is closed, either by a :keyword: `with ` statement
339
344
or by calling ``f.close() ``, attempts to use the file object will
You can’t perform that action at this time.
0 commit comments