##// END OF EJS Templates
tests: filter out PEP 657 error locations in tracebacks (issue6780)...
av6 -
r50764:fe044ce4 stable
parent child Browse files
Show More
@@ -1,39 +1,44
1 1 #!/usr/bin/env python3
2 2
3 3 # Filters traceback lines from stdin.
4 4
5 5
6 6 import io
7 7 import sys
8 8
9 9 if sys.version_info[0] >= 3:
10 10 # Prevent \r from being inserted on Windows.
11 11 sys.stdout = io.TextIOWrapper(
12 12 sys.stdout.buffer,
13 13 sys.stdout.encoding,
14 14 sys.stdout.errors,
15 15 newline="\n",
16 16 line_buffering=sys.stdout.line_buffering,
17 17 )
18 18
19 19 state = 'none'
20 20
21 21 for line in sys.stdin:
22 22 if state == 'none':
23 23 if line.startswith('Traceback '):
24 24 state = 'tb'
25 25
26 26 elif state == 'tb':
27 27 if line.startswith(' File '):
28 28 state = 'file'
29 29 continue
30 30
31 31 elif not line.startswith(' '):
32 32 state = 'none'
33 33
34 elif not line.replace('^', '').replace('~', '').strip():
35 # PEP 657: Fine-grained error locations in tracebacks
36 # ~~~~~~^^^^^^^^^
37 continue
38
34 39 elif state == 'file':
35 40 # Ignore lines after " File "
36 41 state = 'tb'
37 42 continue
38 43
39 44 print(line, end='')
General Comments 0
You need to be logged in to leave comments. Login now