Skip to content

gh-130821: Add type info to error messages for __len__ and __sizeof__#151894

Open
tangyuan0821 wants to merge 2 commits into
python:mainfrom
tangyuan0821:130821
Open

gh-130821: Add type info to error messages for __len__ and __sizeof__#151894
tangyuan0821 wants to merge 2 commits into
python:mainfrom
tangyuan0821:130821

Conversation

@tangyuan0821

@tangyuan0821 tangyuan0821 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Update two more ValueError messages to use the consistent format established in PR #130835 (commit 968f6e5), which added %T type prefix and normalized should → must for invalid return type errors. These two locations were not covered by the original PR or the subsequent follow-ups #144827 and #144737.

Changes:

  • Objects/typeobject.c — slot_sq_length: "len() should return >= 0" → "%T.len() must return >= 0"
  • Python/sysmodule.c — sizeof error: "sizeof() should return >= 0" → "%T.sizeof() must return >= 0"

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.

1 participant