summaryrefslogtreecommitdiffstats
path: root/Misc
diff options
context:
space:
mode:
authorNeil Schemenauer <nas-github@arctrix.com>2017-09-05 03:18:38 (GMT)
committerGitHub <noreply@github.com>2017-09-05 03:18:38 (GMT)
commite38d12ed34870c140016bef1e0ff10c8c3d3f213 (patch)
tree96ec1e59265e883d472ff23437bb5200825ee244 /Misc
parent64263dfd182da4984c51ea33ebd597369d4196f3 (diff)
downloadcpython-e38d12ed34870c140016bef1e0ff10c8c3d3f213.zip
cpython-e38d12ed34870c140016bef1e0ff10c8c3d3f213.tar.gz
cpython-e38d12ed34870c140016bef1e0ff10c8c3d3f213.tar.bz2
bpo-17852: Maintain a list of BufferedWriter objects. Flush them on exit. (#1908)
* Maintain a list of BufferedWriter objects. Flush them on exit. In Python 3, the buffer and the underlying file object are separate and so the order in which objects are finalized matters. This is unlike Python 2 where the file and buffer were a single object and finalization was done for both at the same time. In Python 3, if the file is finalized and closed before the buffer then the data in the buffer is lost. This change adds a doubly linked list of open file buffers. An atexit hook ensures they are flushed before proceeding with interpreter shutdown. This is addition does not remove the need to properly close files as there are other reasons why buffered data could get lost during finalization. Initial patch by Armin Rigo. * Use weakref.WeakSet instead of WeakKeyDictionary. * Simplify buffered double-linked list types. * In _flush_all_writers(), suppress errors from flush(). * Remove NEWS entry, use blurb.
Diffstat (limited to 'Misc')
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2017-09-04-12-46-25.bpo-17852.OxAtCg.rst2
1 files changed, 2 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2017-09-04-12-46-25.bpo-17852.OxAtCg.rst b/Misc/NEWS.d/next/Core and Builtins/2017-09-04-12-46-25.bpo-17852.OxAtCg.rst
new file mode 100644
index 0000000..185664c
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2017-09-04-12-46-25.bpo-17852.OxAtCg.rst
@@ -0,0 +1,2 @@
+Maintain a list of open buffered files, flush them before exiting the
+interpreter. Based on a patch from Armin Rigo.