Skip to content

Commit

Permalink
Always line-buffer stderr for consistency across Python versions
Browse files Browse the repository at this point in the history
The change in default from block-buffering in ≤3.8 to line-buffering in
≥3.9¹ made a Cram test output vary between Python versions (and thus
fail).  I could fix the Cram test various ways, but always
line-buffering stderr makes sense because we're exclusively using it for
messaging/logging.

¹ <https://docs.python.org/3/whatsnew/3.9.html#sys>
  • Loading branch information
tsibley committed Aug 15, 2024
1 parent 99231db commit 8db6617
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions augur/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@ def main():

# Explicitly enable universal newlines mode so we do the right thing.
newline=None,

# By default, stdout is line-buffered when interactive (e.g. for
# consistent stdio interleaving) but block-buffered when not for (I
# assume) better performance.
)
# Apply the above to stderr as well.
sys.stderr.reconfigure(
errors="backslashreplace",
newline=None,

# Always line-buffer stderr since we only use it for messaging, not
# data output. This is the Python default from 3.9 onwards, but we
# also run on 3.8 where it's not. Be consistent regardless of Python
# version.
line_buffering=True,
)

return augur.run( argv[1:] )
Expand Down

0 comments on commit 8db6617

Please sign in to comment.