Skip to content

gh-151461: Fix encoding-related exception handling in file tokenizer#151462

Open
johnslavik wants to merge 9 commits into
python:mainfrom
johnslavik:gh-151461-file-tokenizer-fix-error-handling
Open

gh-151461: Fix encoding-related exception handling in file tokenizer#151462
johnslavik wants to merge 9 commits into
python:mainfrom
johnslavik:gh-151461-file-tokenizer-fix-error-handling

Conversation

@johnslavik

@johnslavik johnslavik commented Jun 14, 2026

Copy link
Copy Markdown
Member

@johnslavik johnslavik added needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 14, 2026
@johnslavik johnslavik changed the title gh-151461: Fix exception handling in file tokenizer gh-151461: Fix encoding-related exception handling in file tokenizer Jun 14, 2026

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. 👍

self.assertIn(line.encode(), err)

def test_coding_spec_unknown_encoding(self):
src = (b'# coding: dict-unpacking-at-home\n'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why use such bizarre name?


def test_coding_spec_unknown_encoding(self):
src = (b'# coding: dict-unpacking-at-home\n'
b'{foo} = {"foo": "bar"}\n')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not even valid syntax.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

While we are here, it would be nice to add also test for non-text encoding, like "hex_codec" or "rot13" (or both).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants