[pypy-issue] Issue #3087: collections.abc + __init_subclass__ failure (pypy/pypy)

Crusader Ky (crusaderky) issues-reply at bitbucket.org
Mon Oct 7 17:14:47 EDT 2019


New issue 3087: collections.abc + __init_subclass__ failure
https://bitbucket.org/pypy/pypy/issues/3087/collectionsabc-__init_subclass__-failure

Crusader Ky (crusaderky):

pypy3.6-v7.1.1-linux64

‌

I have a base class that defines \_\_init\_subclass\_\_ and invokes object.\_\_new\_\_\(cls\) inside it.

If a subclass inherits from it and also from any of the classes from collections.abc, pypy falls over:

‌

```python
from collections.abc import Hashable


class C:
    def __init_subclass__(cls):
        object.__new__(cls)


class D(Hashable, C):
    def __hash__(self):
        return 123
```

Output:

‌

```
Traceback (most recent call last):
  File "t1.py", line 9, in <module>
    class D(Hashable, C):
  File "pypy3.6-v7.1.1-linux64/lib-python/3/abc.py", line 133, in __new__
    cls = super().__new__(mcls, name, bases, namespace)
  File "t1.py", line 6, in __init_subclass__
    object.__new__(cls)
AttributeError: __abstractmethods__
```

‌

Original code, which shows the purpose of this pattern:

[https://github.com/pydata/xarray/blob/4254b4af33843f711459e5242018cd1d678ad3a0/xarray/core/common.py#L186-L208](https://github.com/pydata/xarray/blob/4254b4af33843f711459e5242018cd1d678ad3a0/xarray/core/common.py#L186-L208)

‌




More information about the pypy-issue mailing list