##// END OF EJS Templates
tests: force \n newlines when writing to sys.stdout...
Gregory Szorc -
r45142:d359f0d1 default
parent child Browse files
Show More
@@ -1,29 +1,40
1 1 #!/usr/bin/env python
2 2
3 3 # Filters traceback lines from stdin.
4 4
5 5 from __future__ import absolute_import, print_function
6 6
7 import io
7 8 import sys
8 9
10 if sys.version_info[0] >= 3:
11 # Prevent \r from being inserted on Windows.
12 sys.stdout = io.TextIOWrapper(
13 sys.stdout.buffer,
14 sys.stdout.encoding,
15 sys.stdout.errors,
16 newline="\n",
17 line_buffering=sys.stdout.line_buffering,
18 )
19
9 20 state = 'none'
10 21
11 22 for line in sys.stdin:
12 23 if state == 'none':
13 24 if line.startswith('Traceback '):
14 25 state = 'tb'
15 26
16 27 elif state == 'tb':
17 28 if line.startswith(' File '):
18 29 state = 'file'
19 30 continue
20 31
21 32 elif not line.startswith(' '):
22 33 state = 'none'
23 34
24 35 elif state == 'file':
25 36 # Ignore lines after " File "
26 37 state = 'tb'
27 38 continue
28 39
29 40 print(line, end='')
General Comments 0
You need to be logged in to leave comments. Login now