Skip to content

Report unknown source encodings as ModuleSyntaxError - #966

Open
Aschenbath wants to merge 1 commit into
python-rope:masterfrom
Aschenbath:fix/rope-83-20261122-7c2d-30
Open

Aschenbath wants to merge 1 commit into
python-rope:masterfrom
Aschenbath:fix/rope-83-20261122-7c2d-30

Conversation

@Aschenbath

Copy link
Copy Markdown

Description

An unknown encoding cookie in a source string currently leaks LookupError from the conversion to bytes. Report it as ModuleSyntaxError, consistent with other invalid source input, so editor integrations can handle it through the existing error API.

Fixes #83.

Validation on Windows / Python 3.12: python -m pytest ropetest/pycoretest.py ropetest/contrib/codeassisttest.py -q passes all 300 tests. Both new regressions fail with LookupError against the original code; they cover parsing and code assistance with syntax-fixing enabled.

Checklist

  • I have added tests that prove my fix is effective.
  • I have updated CHANGELOG.md.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uncaught LookupError with an unknown coding: line

1 participant