oracle / graalpython

A Python 3 implementation built on GraalVM
Other
1.21k stars 104 forks source link

TypeError: object.__new__(X): X is not a type object (XXXX) #204

Closed oroppas closed 1 year ago

oroppas commented 3 years ago
from typing import Optional
from pathlib import Path

class Style:

    _path: Optional[Path]

    __slots__ = [
        "_path"
    ]

    def __add__(self, style: Optional["Style"]) -> "Style":
        new_style = self.__new__(Style)

if __name__ == '__main__':
    Style() + Style()

CPython exits with no error but not GraalPython:

Traceback (most recent call last):
  File "/home/ryuta/packages/graalvm/graalpython/rich/new.py", line 16, in <module 'new.py'>
    Style() + Style()
  File "/home/ryuta/packages/graalvm/graalpython/rich/new.py", line 13, in __add__
    new_style = self.__new__(Style)
TypeError: object.__new__(X): X is not a type object (Style)
oroppas commented 1 year ago

I've just tested against main branch and it is fixed! Now GraalPy can work with rich!