changeset 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 cbd2f3509df8
files tests/filtertraceback.py tests/test-http-bad-server.t
diffstat 2 files changed, 9 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/tests/filtertraceback.py	Sat Dec 14 10:32:18 2024 +0000
+++ b/tests/filtertraceback.py	Sat Dec 14 10:40:46 2024 +0000
@@ -15,37 +15,14 @@
     line_buffering=sys.stdout.line_buffering,
 )
 
-state = 'none'
+in_tb = False
 
 for line in sys.stdin:
-    if state == 'none':
-        if line.startswith('Traceback '):
-            state = 'tb'
-
-    elif state == 'tb':
-        if line.startswith('  File '):
-            state = 'file'
-            continue
-
-        elif not line.startswith(' '):
-            state = 'none'
-
-        elif not line.replace('^', '').replace('~', '').strip():
-            # PEP 657: Fine-grained error locations in tracebacks
-            #                       ~~~~~~^^^^^^^^^
-            continue
-        elif line.startswith(' '):
-            # Python 3.13 provide de full statement context
-            continue
-
-    elif state == 'file':
-        # Ignore one line after "  File ", but sometimes "File" lines are
-        # contiguous:
-        #      File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
-        #      File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
-        #      File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
-        if not line.startswith('  File '):
-            state = 'tb'
-        continue
-
-    print(line, end='')
+    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='')
--- a/tests/test-http-bad-server.t	Sat Dec 14 10:32:18 2024 +0000
+++ b/tests/test-http-bad-server.t	Sat Dec 14 10:40:46 2024 +0000
@@ -246,8 +246,6 @@
   read limit reached; closing socket
   $LOCALIP - - [$ERRDATE$] Exception happened during processing request '/?cmd=batch': (glob)
   Traceback (most recent call last):
-          rctx, req, res, self.check_perm (py313 !)
-      ) (py313 !)
   Exception: connection closed after receiving N bytes