X Tutup
Skip to content

Commit e176068

Browse files
committed
don't assume func object will have a __name__ attribute as this will cause a crash on non-Python functions
1 parent b7fd433 commit e176068

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

bpython/inspection.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,10 @@ def getargspec(func, f):
212212
# Check if it's a real bound method or if it's implicitly calling __init__
213213
# (i.e. FooClass(...) and not FooClass.__init__(...) -- the former would
214214
# not take 'self', the latter would:
215+
func_name = getattr(f, '__name__', None)
216+
215217
is_bound_method = ((inspect.ismethod(f) and f.im_self is not None)
216-
or (f.__name__ == '__init__' and not
218+
or (func_name == '__init__' and not
217219
func.endswith('.__init__')))
218220
try:
219221
if py3:

0 commit comments

Comments
 (0)
X Tutup