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

Derived class __init__: __argnames__ definition not inherited #134

Open
ralphwetzel opened this issue Apr 27, 2019 · 0 comments
Open

Derived class __init__: __argnames__ definition not inherited #134

ralphwetzel opened this issue Apr 27, 2019 · 0 comments

Comments

@ralphwetzel
Copy link

The (familiar) setup:

image

app/__init__.pyj:

from control.item import TestA, TestB

class TestApp():
    def __init__(self):
        self.tA = TestA(id="A")
        self.tB = TestB(id="B")
        self.tA.out()
        self.tB.out()

x = TestApp()

control/item.pyj:

class TestA():
    def __init__(self, id):
        self.id = id
    def out(self):
        console.log(self.id)

class TestB(TestA):
    pass

Running test.jsresults in

A
[Object: null prototype] { id: 'B', [Symbol(kwargs-object)]: true }

... expressing that there's an issue with self.id in TestB.

Walking through the code I'm convinced this is due to the fact that
a) TestB is missing the __argnames__ definition that should have been inherited from TestA ...
b) ρσ_interpolate_kwargs thus executes the !f.__argnames__ case ...

function ρσ_interpolate_kwargs(f, supplied_args) {
    var has_prop, kwobj, args, prop;
    if (!f.__argnames__) {
        return f.apply(this, supplied_args);
    }
    has_prop = Object.prototype.hasOwnProperty;
    kwobj = supplied_args.pop();

c) and wrongly packs the provided parameters into arguments:

TestA/arguments at the end of ρσ_interpolate_kwargs:
image

TestB/argumentsat the end of ρσ_interpolate_kwargs:
image

Consequentially the initialization of self.id in TestB pulls the wrong parameter - generating the issue indicated.

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