MCPcopy Create free account
hub / github.com/apache/tvm-ffi / _parse_backtrace

Function _parse_backtrace

python/tvm_ffi/error.py:31–57  ·  view source on GitHub ↗

Parse the backtrace string into a list of (filename, lineno, func). Parameters ---------- backtrace The backtrace string. Returns ------- result The list of (filename, lineno, func)

(backtrace: str)

Source from the content-addressed store, hash-verified

29
30
31def _parse_backtrace(backtrace: str) -> list[tuple[str, int, str]]:
32 """Parse the backtrace string into a list of (filename, lineno, func).
33
34 Parameters
35 ----------
36 backtrace
37 The backtrace string.
38
39 Returns
40 -------
41 result
42 The list of (filename, lineno, func)
43
44 """
45 pattern = r'File "(.+?)", line (\d+), in (.+)'
46 result = []
47 for line in backtrace.split("\n"):
48 match = re.match(pattern, line.strip())
49 if match:
50 try:
51 filename = match.group(1)
52 lineno = int(match.group(2))
53 func = match.group(3)
54 result.append((filename, lineno, func))
55 except ValueError:
56 pass
57 return result
58
59
60class TracebackManager:

Callers 1

_with_append_backtraceFunction · 0.85

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected