##// 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 #!/usr/bin/env python3
1 #!/usr/bin/env python3
2
2
3 # Filters traceback lines from stdin.
3 # Filters traceback lines from stdin.
4
4
5
5
6 import io
6 import io
7 import sys
7 import sys
8
8
9 if sys.version_info[0] >= 3:
9 if sys.version_info[0] >= 3:
10 # Prevent \r from being inserted on Windows.
10 # Prevent \r from being inserted on Windows.
11 sys.stdout = io.TextIOWrapper(
11 sys.stdout = io.TextIOWrapper(
12 sys.stdout.buffer,
12 sys.stdout.buffer,
13 sys.stdout.encoding,
13 sys.stdout.encoding,
14 sys.stdout.errors,
14 sys.stdout.errors,
15 newline="\n",
15 newline="\n",
16 line_buffering=sys.stdout.line_buffering,
16 line_buffering=sys.stdout.line_buffering,
17 )
17 )
18
18
19 state = 'none'
19 state = 'none'
20
20
21 for line in sys.stdin:
21 for line in sys.stdin:
22 if state == 'none':
22 if state == 'none':
23 if line.startswith('Traceback '):
23 if line.startswith('Traceback '):
24 state = 'tb'
24 state = 'tb'
25
25
26 elif state == 'tb':
26 elif state == 'tb':
27 if line.startswith(' File '):
27 if line.startswith(' File '):
28 state = 'file'
28 state = 'file'
29 continue
29 continue
30
30
31 elif not line.startswith(' '):
31 elif not line.startswith(' '):
32 state = 'none'
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 elif state == 'file':
39 elif state == 'file':
35 # Ignore lines after " File "
40 # Ignore lines after " File "
36 state = 'tb'
41 state = 'tb'
37 continue
42 continue
38
43
39 print(line, end='')
44 print(line, end='')
General Comments 0
You need to be logged in to leave comments. Login now