◐ Shell
clean mode source ↗

Fix _ctypes.Array base and metaclass by youknowone · Pull Request #5620 · RustPython/RustPython

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following causes different results in python and this branch:

from _ctypes import _SimpleCData

class c_short(_SimpleCData):
    _type_ = "h"
print(c_short.__mul__(5))

Python:

<class '__main__.c_short_Array_5'>

RustPython:

Traceback (most recent call last):
  File "tmp.py", line 6, in <module>
    print(c_short.__mul__(5))
TypeError: unexpected payload for __repr__

Note that on main the repr is simply incorrect (I haven't checked explicitly, but in previous testing, that is what I saw).

I don't think the cpython implementation PyCArrayType does anything special, so I assume this is a general rustpython compatibility.