Skip to content

Fix unicode handling in patched ast - #872

Open
lieryan wants to merge 7 commits into
masterfrom
lieryan-implement-ast-lines-adapter
Open

Fix unicode handling in patched ast#872
lieryan wants to merge 7 commits into
masterfrom
lieryan-implement-ast-lines-adapter

Conversation

@lieryan

@lieryan lieryan commented Sep 7, 2026

Copy link
Copy Markdown
Member

Description

Please include a summary of the change and which issue is fixed.

Checklist (delete if not relevant):

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

@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.33%. Comparing base (f005ac7) to head (a6e3025).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #872      +/-   ##
==========================================
+ Coverage   95.29%   95.33%   +0.04%     
==========================================
  Files         134      134              
  Lines       26541    26766     +225     
==========================================
+ Hits        25291    25517     +226     
+ Misses       1250     1249       -1     

☔ 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.

@lieryan
lieryan force-pushed the lieryan-implement-ast-lines-adapter branch from c543d4c to 17a258f Compare September 7, 2026 03:09
ASTLinesAdapter uses ast-produced col_offset/end_col_offset which are
produced by the python's own parser to calculate convert offsets to str
offset, which should be more reliable than the ad-hoc calculations that
generally would only have worked with ASCII-only source code.
col_offset/end_col_offset uses utf-8 offset which generally only
accidentally coincides with str-offset that rope uses as node.region.

ASTLinesAdapter ensures correct computation of offset.
All slices are handled by __getitem__() since Python 3.
Now we have a better ASTLinesAdapter that actually handles unicode
correctly.
@lieryan
lieryan force-pushed the lieryan-implement-ast-lines-adapter branch from 17a258f to a6e3025 Compare September 7, 2026 03:17
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.

1 participant