Skip to content

Fix panic in D208 with multibyte indent#9147

Merged
charliermarsh merged 1 commit into
mainfrom
konstin/fix-gh9080
Dec 15, 2023
Merged

Fix panic in D208 with multibyte indent#9147
charliermarsh merged 1 commit into
mainfrom
konstin/fix-gh9080

Conversation

@konstin

@konstin konstin commented Dec 15, 2023

Copy link
Copy Markdown
Member

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
```
@github-actions

Copy link
Copy Markdown
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@charliermarsh charliermarsh 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.

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
@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