我有这个:
if fn is not None:
print('ok we are running the func')
fn(d.error, d)
print('ok we ran the func')
return
我注销了:
ok we are running the func
我登录它时,fn对象如下所示:
here is fn: <function LMXClient.make_lock_acquired.<locals>.on_lock_acquired at 0x7f344f97c488>
定义如下:
def make_lock_acquired(self,cb):
print('lock was acquired.')
有人知道我为什么不能打电话吗?没有try / catch,所以据我所知,错误不会被吞没。
更新:是的,当我明确包装try / catch
时,Python吞下了错误或其他内容。 try:
fn()
except:
print("Unexpected error:", sys.exc_info()[0])
然后我收到此错误:
Unexpected error: (<class 'TypeError'>, TypeError("make_lock_acquired() missing 1 required positional argument: 'cb'",), <traceback object at 0x7f0cf873ccc8>)
不确定为什么