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

Python Binding not working correctly with multiple inheritance #55

Closed
mbarger99 opened this issue Nov 12, 2018 · 1 comment
Closed

Python Binding not working correctly with multiple inheritance #55

mbarger99 opened this issue Nov 12, 2018 · 1 comment
Assignees

Comments

@mbarger99
Copy link
Contributor

I have a case like:

class MyClass(GravitySubscriber, GravityRequestor):
    def __init__(self):
        super(MyClass, self)__init__()

then I try to subscribe like:

self.gravityNode.subscribe("MySub", self)

That works, but then when I try to make an asynchronous request like:

self.gravityNode.request("MyService", reqGDP, self)

I get an error that the args are the wrong type or number. If I switch the order of the parent classes in the MyClass declaration, then the call to subscribe fails instead with the same message.

It looks like the problem is the type checking performed in the generated C++ code - for some reason it's only seeing that self is an instance of the first parent class, not the second.

@mbarger99 mbarger99 self-assigned this Nov 12, 2018
@mbarger99
Copy link
Contributor Author

The issue here is that swig does not support cooperative subclassing (i.e. generated Python classes to not call super in their __init__ methods).

We can look at adding this in the code generated here, but in the mean time there's an easy workaround: use the older style explicit calls to __init__ for each parent class. Instead of the code to initialize the MyClass class above, you'd have:

class MyClass(GravityRequestor, GravitySubscriber):
    def __init__(self):
        GravityRequestor.__init__(self)
        GravitySubscriber.__init__(self)

mbarger99 added a commit that referenced this issue May 2, 2019
…it__ on each gravity parent class to ensure that swig correctly sets up the underlying proxy object. Addresses Issue #55.
mbarger99 added a commit that referenced this issue May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant