Skip to content

Sequence-like subclass __radd__ fallback regression #146587

Closed

Description

@inventshah

Bug report

Bug description:

In the 3.15 alphas, the + operator does not dispatch to obj.__radd__ when the left hand object inherits from a sequence like class (list, tuple, ...), but does if it is a base instance.

class A:
    def __radd__(self, other): ...

class B(tuple): ...

() + A()  # No error
B() + A() # TypeError: can only concatenate tuple (not "A") to tuple

I originally ran into the issue with a NamedTuple, but looks like subclasses of array.array, bytearray, bytes, collections.deque, list, str, and tuple all raise the error.

Works in 3.14.3. git bisect'd to e6e376a, so something in the resolution between nb_add and sq_concat may have changed while optimizing (* has a similar problem with __rmul__ mapping to nb_multiply and sq_repeat).

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

Activity

  1. added
    type-bug
    on Mar 29, 2026
  2. inventshah commented on Mar 29, 2026

    @inventshah
    ContributorAuthor

    cc @sergey-miryanov as the bisect'd PR author

  3. added
    interpreter-core
    3.15
    on Mar 29, 2026
  4. sergey-miryanov commented on Mar 29, 2026

    @sergey-miryanov
    Contributor

    Will take a look soon

  5. serhiy-storchaka commented on Mar 29, 2026

    @serhiy-storchaka
    Member
  6. added
    3.14
    and removed
    3.14
    on Mar 29, 2026
  7. kumaraditya303 commented on Mar 29, 2026

    @kumaraditya303
    Contributor

    I'm working on a fix.

  8. kumaraditya303 commented on Mar 29, 2026

    @kumaraditya303
    Contributor

    PR #146593 fixes this.

  9. added a commit that references this issue on Mar 30, 2026
  10. added a commit that references this issue on Apr 16, 2026
  11. added a commit that references this issue on Apr 25, 2026
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

    3.15interpreter-corerelease-blockertype-bug

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions