BUG: AttributeError: 'function' object has no attribute 'im_func' on Python 3