-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Cannot register a class with an abstract method. #1359
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
Comments
It looks like pybind only calls the metaclass tp_alloc slot when creating a new type, not tp_new, so in your example I'm not sure there's a good solution here, unfortunately, not without some substantial hacking at least. |
+1 for any type of workaround for this. |
Does the info under #5015 help? (I'm honestly not sure, mainly because I don't understand what exactly the original problem was/is.) |
Hi,
I am trying to register a class that has an abstract method. The idea is for clients to define the method in their subclasses. However, the registration fails.
Before I forget, I am running on Ubuntu 16.04, using pybind11 version 2.2.2, python 2.7.12, g++ version 5.4.0, and -std=c++11.
Here is what I am trying to do:
Here, I have a class that offers the save() function. But I require clients to create a subclass and define the draw() function.
When I compile and run the code, I get the following error:
Since ABCMeta is trying to add _abc_cache and other attributes to my base class, I thought adding dynamic_attr() might help. I get the same error message with the following:
I would appreciate any help on this. Thank you.
In the attached file, I am embedding the python interpreter so that I do not need a python script to import my example module.
main.cpp.txt
The text was updated successfully, but these errors were encountered: