pypy3.7/8: __mro_entries__ doesn't work properly
Since Python 3.7 (PEP 560), CPython has supported the __mro_entries__
method to customize the base class list.
However, pypy3.7 and 3.8 do not properly support this method:
% ~/.pyenv/versions/pypy3.8-7.3.11/bin/python
Python 3.8.16 (a9dbdca6fc3286b0addd2240f11d97d8e8de187a, Dec 29 2022, 11:45:30)
[PyPy 7.3.11 with GCC Apple LLVM 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>> def f(): pass
>>>> f.__mro_entries__ = lambda _: (int,)
>>>> class x(f): pass
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: metaclass found to be 'function', but calling <class 'function'> with args ('x', (<function f at 0x0000000148314ca0>,), ...) raised "'internal-code' object expected, got 'str' instead"
>>>>
For comparison:
% python3.8
Python 3.8.16 (default, Dec 26 2022, 20:36:56)
[Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(): pass
...
>>> f.__mro_entries__ = lambda _: (int,)
>>> class x(f): pass
...
>>> x.__bases__
(<class 'int'>,)
>>>
pypy3.9, however, behaves correctly.