RustPython icon indicating copy to clipboard operation
RustPython copied to clipboard

PyNumber protocol does not check for implementations in base classes

Open arihant2math opened this issue 8 months ago • 2 comments

PySequence and others do this, but PyNumber does not. This leads to #5711 and ctypes data multiplication not working.

I haven't checked if cpython just expects slots to be inherited or does this.

arihant2math avatar Apr 21 '25 07:04 arihant2math

@youknowone I'm curious as to how I could attempt a fix for this. It seems as though PyNumber has been defined slightly differently than the other protocols, and I think this is intentional.

arihant2math avatar Jun 28 '25 17:06 arihant2math

It's been so long time ago I worked on slots. I forgot the most of details.

CPython basically inherits slots not to require subtypes to crawl up the entire mro. But we don't have it. We check base classes to avoid this limitation. About PyNumber, checking base classes made another problem like referencing PyBaseObject's PyNumber, which shouldn't happen.

If PyNumber slots are fairly well isolated from others, we will be able to implement slot inheritance only for PyNumber

youknowone avatar Jun 29 '25 04:06 youknowone