Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Sequence-like subclass __radd__ fallback regression #146587

Copy link
Copy link
@inventshah

Description

@inventshah
Issue body actions

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

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)release-blockertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    No fields configured for issues without a type.

    Projects

    Status
    Done
    Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.