Skip to content

gh-130821: Improve error messages for magic methods returning wrong type#154606

Closed
prabhleen-kaurr wants to merge 1 commit into
python:mainfrom
prabhleen-kaurr:fix-error-messages-magic-methods
Closed

gh-130821: Improve error messages for magic methods returning wrong type#154606
prabhleen-kaurr wants to merge 1 commit into
python:mainfrom
prabhleen-kaurr:fix-error-messages-magic-methods

Conversation

@prabhleen-kaurr

@prabhleen-kaurr prabhleen-kaurr commented Jul 24, 2026

Copy link
Copy Markdown

Fixes remaining inconsistent error messages for magic methods that
return the wrong type, as part of issue #130821.

Changes made to use the consistent %T.__method__() must return ..., not %T
format established in previous PRs (#130835, #144737):

  • Objects/typeobject.c: Fixed __hash__, __init__, __getnewargs_ex__,
    and __getnewargs__ error messages
  • Python/bytecodes.c: Fixed __init__ error message in EXIT_INIT_CHECK

This follows the pattern established by the merged PRs for this issue.

@bedevere-app

bedevere-app Bot commented Jul 24, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@python-cla-bot

python-cla-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@picnixz

picnixz commented Jul 24, 2026

Copy link
Copy Markdown
Member

This is a dupliocate of #144827. Don't create a PR when one already exists, or at leashttps://github.com/python/cpython/pull/144827t ask the author of the original PR if they intend to continue their work.

@picnixz picnixz closed this Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants