krzema12 / kotlin-python

Python target for the Kotlin Programming Language. See https://github.com/krzema12/kotlin-python/tree/python-backend/python
https://discuss.kotlinlang.org/t/idea-python-backend/19852
47 stars 1 forks source link

Adjust for no `__new__` method on MicroPython #88

Open krzema12 opened 2 years ago

krzema12 commented 2 years ago

When trying to run e2e tests for MicroPython, the constructors test fails with:

  File "python/e2e-tests/out/python-consumer.py", line 6, in <module>
  File "/home/piotr/repos/priv/kotlin-python/python/e2e-tests/out/compiled.py", line 13692, in multi12
  File "/home/piotr/repos/priv/kotlin-python/python/e2e-tests/out/compiled.py", line 13670, in MultiConstructors1_init__Create_
AttributeError: type object 'MultiConstructors1' has no attribute '__new__'

Looks like __new__ is another magic method unavailable on MicroPython. We had to use + instead of __add__ already. Not sure if there's an equivalent here, but still it's a must to fix it given we want to support MP.

krzema12 commented 2 years ago

TODO: check why __new__ (magic method) was used, and if some non-magic method can be used instead.