Skip to content

Commit efa8b04

Browse files
author
dengsheng.chen
committed
Fix 'builtin-code' object has no attribute 'co_filename' under pypy
1 parent 5b7d384 commit efa8b04

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

stackprinter/frame_formatting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def hide(name):
242242
if callable(value):
243243
qualified_name, path, *_ = inspect_callable(value)
244244
is_builtin = value.__class__.__name__ == 'builtin_function_or_method'
245-
is_boring = is_builtin or (qualified_name == name)
245+
is_boring = is_builtin or (qualified_name == name) or (path is None)
246246
is_suppressed = match(path, self.suppressed_paths)
247247
return is_boring or is_suppressed
248248
return False

stackprinter/utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,16 @@ def inspect_callable(f):
3737
except AttributeError:
3838
qname = None
3939

40-
filepath = code.co_filename
41-
ln = code.co_firstlineno
40+
try:
41+
filepath = code.co_filename
42+
except AttributeError:
43+
filepath = None
44+
45+
try:
46+
ln = code.co_firstlineno
47+
except AttributeError:
48+
ln = None
49+
4250
return qname, filepath, owner, ln
4351

4452

0 commit comments

Comments
 (0)