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.

@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.45%. Comparing base (ff8a306) to head (a1bf80b).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #966   +/-   ##
=======================================
  Coverage   95.44%   95.45%           
=======================================
  Files         134      134           
  Lines       26910    26921   +11     
=======================================
+ Hits        25685    25698   +13     
+ Misses       1225     1223    -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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