You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
StackOverflowException on calling super().method() #2574
frompathlibimportPathimportclrclr.AddReference(str(Path(__file__).parent/'TestLib.dll'))
fromTestLibimportBaseClass, DerivedClassclassTestClass(DerivedClass):
__namespace__='CrlTest'defFoo(self):
return'Test'+super().Foo()
defBar(self):
# This work fine# return 'Test' + DerivedClass.Bar(self)# This calls TestClass::Bar for some reasonreturn'Test'+super().Bar()
if__name__=='__main__':
stc=TestClass()
print('Foo() -> '+stc.Foo())
print('Bar() -> '+stc.Bar())
Python script output:
Foo() -> TestDerivedFoo
Process is terminated due to StackOverflowException.
For some reason calling super().Bar() results in calling TestClass.Bar(self) instead of DerivedClass.Bar(self), which in the end results in infinite recursion. Calling DerivedClass.Bar(self) directly works as expected.
It seem to be related to the fact that the method you try to override in Python is not defined in the immediate parent class, since Foo in the example works fine.
Activity