◐ Shell
clean mode source ↗

Raise TypeError when calling __new__ unsafely by garychia · Pull Request #4455 · RustPython/RustPython

Hi, @DimitrisJim! I was struggling to solve the problem that happens when running the test_ast test as I mentioned before. Based on my observation, RustPython tried to construct an N object by using object.__new__, which is not safe. But I have no idea why it behaved this way and whether it relates to my code.
This piece of code triggered the problem:

class N(ast.Num):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.z = 'spam'
class N2(ast.Num):
pass
n = N(42)