From 3c4b232ee60d7d870cc05103a83762cd81821711 Mon Sep 17 00:00:00 2001 From: Ahmet Faruk Ilhan Date: Sun, 5 Jul 2026 03:08:45 +0200 Subject: [PATCH] gh-56229: Document flush expectation for stdout and stderr replacements --- Doc/library/sys.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index d0fe0625deb5133..4121057539c9d2e 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -2180,6 +2180,10 @@ always available. Unless explicitly noted otherwise, all variables are read-only may be replaced with file-like objects like :class:`io.StringIO` which do not support the :attr:`!buffer` attribute. + At interpreter shutdown, the ``stdout`` and ``stderr`` streams are + flushed, so objects used to replace them should provide a ``flush()`` + method. + .. data:: __stdin__ __stdout__