Skip to content

gh-130821: Make error messages consistent in Modules/#144737

Open
Cityfishman wants to merge 1 commit into
python:mainfrom
Cityfishman:fix-issue-130821-modules
Open

gh-130821: Make error messages consistent in Modules/#144737
Cityfishman wants to merge 1 commit into
python:mainfrom
Cityfishman:fix-issue-130821-modules

Conversation

@Cityfishman
Copy link
Copy Markdown

@Cityfishman Cityfishman commented Feb 12, 2026

Update error messages in Modules/ directory to use consistent format with %T formatter for type names, similar to changes made in PR #130835 for Objects/ directory.

Changes:

  • Modules/_abc.c: items() error message
  • Modules/_datetimemodule.c: divmod() error message
  • Modules/_pickle.c: read() error message
  • Modules/_io/bufferedio.c: read() and readall() error messages
  • Modules/_io/iobase.c: read() error message
  • Modules/_io/textio.c: decoder and encoder error messages
  • Modules/_csv.c: iterator error message

Update error messages in Modules/ directory to use consistent format
with %T formatter for type names, similar to changes made in PR python#130835
for Objects/ directory.

Changes:
- Modules/_abc.c: items() error message
- Modules/_datetimemodule.c: divmod() error message
- Modules/_pickle.c: read() error message
- Modules/_io/bufferedio.c: read() and readall() error messages
- Modules/_io/iobase.c: read() error message
- Modules/_io/textio.c: decoder and encoder error messages
- Modules/_csv.c: iterator error message
@python-cla-bot
Copy link
Copy Markdown

python-cla-bot Bot commented Feb 12, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Feb 12, 2026

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.

Comment thread Modules/_pickle.c
@@ -1302,8 +1302,8 @@ _Unpickler_ReadIntoFromFile(PickleState *state, UnpicklerObject *self, char *buf
}
if (!PyBytes_Check(data)) {
PyErr_Format(PyExc_ValueError,
Copy link
Copy Markdown
Contributor

@brijkapadia brijkapadia Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems strange that this raises a ValueError and not a TypeError since the error is that the return value of read() is not a bytes object, but instead a different type. Not sure the potential impact of changing this from a ValueError to a TypeError, but a TypeError feels like the better option as it makes it consistent with all the other changes in this PR and also in #130835.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants