rapydscript-ng
rapydscript-ng copied to clipboard
Derived class __init__: __argnames__ definition not inherited
The (familiar) setup:
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:

TestB/argumentsat the end of ρσ_interpolate_kwargs:

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