Mercurial > public > mercurial-scm > hg
view tests/filtertraceback.py @ 52510:4f9a3347bfb4
filter-traceback: simplify handling
With all the recent change in Python, the best we need and can do is "ignore all
line starting with a space after a line starting with "Traceback ".
So let us simplify the script.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 14 Dec 2024 10:40:46 +0000 |
parents | 3afe0be4f4b7 |
children |
line wrap: on
line source
#!/usr/bin/env python3 # Filters traceback lines from stdin. import io import sys # Prevent \r from being inserted on Windows. sys.stdout = io.TextIOWrapper( sys.stdout.buffer, sys.stdout.encoding, sys.stdout.errors, newline="\n", line_buffering=sys.stdout.line_buffering, ) in_tb = False for line in sys.stdin: do_print = not in_tb if line.startswith('Traceback '): in_tb = True elif not line.startswith(' '): in_tb = False do_print = True if do_print: print(line, end='')