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

Crash with line-length 18 and backslash in docstring #3425

Closed
JelleZijlstra opened this issue Dec 10, 2022 · 1 comment · Fixed by #3451
Closed

Crash with line-length 18 and backslash in docstring #3425

JelleZijlstra opened this issue Dec 10, 2022 · 1 comment · Fixed by #3451
Labels
C: crash Black is crashing C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. F: docstrings How we format docstrings T: bug Something isn't working

Comments

@JelleZijlstra
Copy link
Collaborator

JelleZijlstra commented Dec 10, 2022

Code:

def multiline_backslash_2():
    """
    hey there \ """

On Black 22.12.0:

% black --preview --diff tests/data/miscellaneous/docstring_no_string_normalization.py -l 18
error: cannot format tests/data/miscellaneous/docstring_no_string_normalization.py: INTERNAL ERROR: Black produced code that is not equivalent to the source.  Please report a bug on https://github.com/psf/black/issues.  This diff might be helpful: /var/folders/3b/k964cnv10097wzj3h7w07fww0000gp/T/blk_jh8pb654.log

Oh no! 💥 💔 💥
1 file would fail to reformat.
% cat /var/folders/3b/k964cnv10097wzj3h7w07fww0000gp/T/blk_jh8pb654.log

--- src
+++ dst
@@ -18,11 +18,11 @@
           value=
             Constant(
               kind=
                 None,  # NoneType
               value=
-                'hey there \\',  # str
+                'hey there',  # str
             )  # /Constant
         )  # /Expr
       decorator_list=
       name=
         'multiline_backslash_2',  # str
@JelleZijlstra JelleZijlstra added T: bug Something isn't working C: crash Black is crashing F: docstrings How we format docstrings labels Dec 10, 2022
@JelleZijlstra
Copy link
Collaborator Author

Also reproduces with a reasonable line length if you make the example longer:

def multiline_backslash_2():
    """
    hey there hello guten tag hi hoow are you ola zdravstvuyte ciao como estas ca va \ """

@JelleZijlstra JelleZijlstra added the C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. label Dec 19, 2022
JelleZijlstra added a commit to JelleZijlstra/black that referenced this issue Dec 19, 2022
The crash reproes on 22.12.1 but appears to be fixed on main; add
a test to make sure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: crash Black is crashing C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. F: docstrings How we format docstrings T: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant