problem with super() call
jggatc opened this issue · 0 comments
jggatc commented
Discovered an issue with super()
call when the method is an alias identifier such as update
. If a subclass method calls super().update()
it is translated to __super__ (SubCls, 'update') (self)
rather than using the alias py_update
and results in Superclass method not found
error. There is no issue with Cls.update(self)
call.
test_super.py:
class Cls:
def __init__(self):
self.count = 0
def update_count(self):
self.count += 1
def update(self):
self.count += 1
class SubCls(Cls):
def update_count(self):
super().update_count()
def update(self):
super().update()
cls = SubCls()
print('super().update_count call')
cls.update_count()
print('count:', cls.count)
print('super().update call')
cls.update()
print('count:', cls.count)
transcrypt -n test_super.py
console:
call: super().update_count
count: 1
call: super().update
Error 'Superclass method not found'
stack:
at __target__/org.transcrypt.__runtime__.js:1840:17
at Function.__new__ (__target__/org.transcrypt.__runtime__.js:152:23)
at new cls (__target__/org.transcrypt.__runtime__.js:91:24)
at __super__ (__target__/org.transcrypt.__runtime__.js:186:11)
at __target__/test_super.js:22:3
at Function.<anonymous> (__target__/org.transcrypt.__runtime__.js:57:29)
at __target__/test_super.js:30:5
Environment:
Linux
Python 3.9.6
Transcrypt 3.9.0
Chrome/Firefox