GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — right operand's __radd__ method is ignored when the left operand is a NamedTuple (3.15.0a7) · Issue #146592 · python/cpython

right operand's __radd__ method is ignored when the left operand is a NamedTuple (3.15.0a7) #146592

New issue
Copy link
New issue
Copy link
Closed as duplicate
Closed as duplicate
right operand's __radd__ method is ignored when the left operand is a NamedTuple (3.15.0a7)#146592
Copy link
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@neutrinoceros
neutrinoceros
opened on Mar 29, 2026
Issue body actions

Bug report

Bug description:

I'm seeing a regression in how an + operation is resolved between a NamedTuple and an arbitrary type with a __radd__ implementation, which looks like an LSP violation since builtin tuple instance still behave the same as with Python 3.14

from typing import NamedTuple

class T(NamedTuple):
     x: int

class A:
    def __init__(self, *args):
       self.lst = list(args)
    def __radd__(self, other):
        return A(*self.lst, other)
 
print(((1,)+A()).lst) # [(1,)]
print((T(x=1)+A()).lst) # raises
Traceback (most recent call last):
  File "/Users/clm/dev/gh/astropy/astropy/t.py", line 13, in <module>
    print((T(x=1)+A()).lst) # raises
           ~~~~~~^~~~
TypeError: can only concatenate tuple (not "A") to tuple

The __radd__ implementation on the right operand appears to be entirely skipped, and we only see the error from the left operand's __add__ method.

This was originally discovered in astropy's test suite.

xref numpy/numpy#31088
xref astropy/astropy#19503

CPython versions tested on:

3.15

Operating systems tested on:

Linux

Reacted by Joren Hammudoglu

Activity

  1. neutrinoceros
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Mar 29, 2026
  2. serhiy-storchaka commented on Mar 29, 2026

    @serhiy-storchaka
    serhiy-storchaka
    on Mar 29, 2026
    Member
    More actions

    This looks like a duplicate of #146587 opened three hours ago.

    Did you guys get this from the same source?

  3. neutrinoceros commented on Mar 29, 2026

    @neutrinoceros
    neutrinoceros
    on Mar 29, 2026
    ContributorAuthor
    More actions

    Did you guys get this from the same source?

    Not that I'm aware. This looks entirely coincidental to me, but of course I'm okay with closing this one as a dupe. Thanks for pointing it out !

  4. neutrinoceros
    closed this as a duplicateof Sequence-like subclass __radd__ fallback regression #146587 on Mar 29, 2026
  5. neutrinoceros commented on Mar 29, 2026

    @neutrinoceros
    neutrinoceros
    on Mar 29, 2026
    ContributorAuthor
    More actions

    Not that I'm aware.

    to be clear what I meant here: I discovered the problem independently about 13h ago and reported it in astropy, then numpy.
    I don't know wether #146587 was an entirely independent discovery or if it built from my early (misplaced) reports.

    Reacted by Serhiy Storchaka
  6. serhiy-storchaka commented on Mar 29, 2026

    @serhiy-storchaka
    serhiy-storchaka
    on Mar 29, 2026
    Member
    More actions

    Most likely.

  7. inventshah commented on Mar 29, 2026

    @inventshah
    inventshah
    on Mar 29, 2026
    Contributor
    More actions

    Coincidental, but glad there is an established use case! I was only on the beta to play with Tachyon, and couldn't pass up an opportunity to git bisect.

    Reacted by Clément Robert
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

    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.