Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic in D208 with multibyte indent #9147

Merged
merged 1 commit into from
Dec 15, 2023
Merged

Conversation

konstin
Copy link
Member

@konstin konstin commented Dec 15, 2023

Fix #9080

Example, where [] is a 2 byte non-breaking space:

def f():
    """ Docstring header
^^^^ Real indentation is 4 chars
      docstring body, over-indented
^^^^^^ Over-indentation is 6 - 4 = 2 chars due to this line
   [] []  docstring body 2, further indented
^^^^^ We take these 4 chars/5 bytes to match the docstring ...
     ^^^ ... and these 2 chars/3 bytes to remove the `over_indented_size` ...
        ^^ ... but preserve this real indent

Fix #9080

Example, where `[]` is a 2 byte non-breaking space:
```
def f():
    """
^^^^ Real indentation is 4 chars
      overindented
^^^^^^ overindentation is 6 - 4 = 2 chars due to this line
   [] []  further indented
^^^^^ we take these 4 chars/5 bytes to match the docstring ...
     ^^^ ... and these 2 chars/3 bytes to remove the `over_indented_size` ...
        ^^ ... but preserve this real indent
```
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

We've had so many fuzzer bugs related to this, strings are really hard.

@charliermarsh charliermarsh added bug Something isn't working fuzzer Surfaced via fuzzing. labels Dec 15, 2023
@charliermarsh charliermarsh merged commit 82731b8 into main Dec 15, 2023
17 checks passed
@charliermarsh charliermarsh deleted the konstin/fix-gh9080 branch December 15, 2023 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fuzzer Surfaced via fuzzing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rule D208 cause panic
3 participants