Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use __code__ to detect Python callable object #2008

Open
buckle2000 opened this issue Mar 1, 2020 · 3 comments
Open

Don't use __code__ to detect Python callable object #2008

buckle2000 opened this issue Mar 1, 2020 · 3 comments

Comments

@buckle2000
Copy link

Expected Behavior

dlib.find_max_global (Python) should work on every callable object.

Current Behavior

It only works on objects with attribute __code__.

Steps to Reproduce

import dlib
from functools import partial
def f(arg0):
    return 0
dlib.find_max_global(partial(f, 2), [0.], [1.], 100)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-112-da98f75572a0> in <module>
----> 1 dlib.find_max_global(partial(f, 2), [0.], [1.], 100)

AttributeError: 'functools.partial' object has no attribute '__code__'
  • Version: dlib==19.19.0 (Python package)
  • Where did you get dlib: pip/pypi
  • Platform: Linux 5.0.0-38-generic error compiling imglab tool #41-Ubuntu
  • Compiler: gcc version 8.3.0 (Ubuntu 8.3.0-6ubuntu1)
@buckle2000
Copy link
Author

@davisking
Copy link
Owner

That would be cool. You should submit a PR :)

@buckle2000
Copy link
Author

But I don't know C++ 🤕

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants