get_original_fn() fails on objects with C impl
Closed this issue · 0 comments
besfahbod commented
We have this:
Line 36 in d7a757b
This assumes that it's okay to set .original_fn
attribute on the fn
item. However, that's not the case when the method's object (and, iirc, for the case of a function itself) is implemented in C/Cython.
Here's an example of the error raised:
original_target = qcore.inspection.get_original_fn(outer_target)
File "qcore/inspection.py", line 27, in qcore.inspection.get_original_fn
File "qcore/inspection.py", line 36, in qcore.inspection.get_original_fn
AttributeError: 'method' object has no attribute 'original_fn'
A simple try/except should do the job, I think. I'll submit a patch.