Skip to content

PyNumber protocol does not check for implementations in base classes #5726

Closed

Description

@arihant2math

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.

Activity

  1. added
    C-bugSomething isn't working
    C-compatA discrepancy between RustPython and CPython
    on Apr 21, 2025
  2. added theissue type on Apr 21, 2025
  3. arihant2math commented on Jun 28, 2025

    @arihant2math
    ContributorAuthor

    @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.

  4. added
    A-vmArea: virtual machine
    and removed
    C-bugSomething isn't working
    on Jun 28, 2025
  5. youknowone commented on Jun 29, 2025

    @youknowone
    Member

    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

  6. youknowone commented on Jan 2, 2026

    @youknowone
    Member

    Long rally including #6622 solved hopefully all the slot inheritance issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-vmArea: virtual machineC-compatA discrepancy between RustPython and CPython

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions