[New-bugs-announce] [issue41051] Flush file after warning is written

Manuel Jacob report at bugs.python.org
Sat Jun 20 08:34:37 EDT 2020

New submission from Manuel Jacob <me at manueljacob.de>:

Calling warnings.warn() will write to a file, but not flush it. On Python 3.9+, it won’t usually be a problem because the file is most likely stderr, which is always line-buffered. However, on older Python versions or if a different file is used, the current behavior unnecessarily delays the output of the warning. This is especially problematic if the warning is about buffering behavior itself, as e.g. caused by `open('/tmp/test', 'wb', buffering=1)`.

messages: 371934
nosy: mjacob
priority: normal
severity: normal
status: open
title: Flush file after warning is written

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list