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

When reformatting a triple-quote string, black fails with an INTERNAL ERROR: Black produced code that is not equivalent to the source #4288

Closed
aaribaud opened this issue Mar 22, 2024 · 0 comments · Fixed by #4290
Labels
T: bug Something isn't working

Comments

@aaribaud
Copy link

Describe the bug

When reformatting a triple-quote string, black fails with an internal error.

To Reproduce

Take this code:

if __name__ == "__main__":
    """     This string...
    ... will confuse black.
    
    """
    pass

And run it with these arguments:

$ black file.py

The resulting error is:

error: cannot format blackerrdemo.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: /tmp/blk_d030my1_.log

Oh no! 💥 💔 💥
1 file failed to reformat.

Expected behavior

Black should leave the string untouched or, if it decides to reformat it, reformat it without failure.

Environment

  • Black's version: [24.3.0 (compiled: yes), 24.3.1.dev5+gc9d2635 (compiled: no)]
  • OS and Python version: [Debian Linux 12 (Bookworm)/Python 3.11.2]

Additional context

Reproduced with branch main at commit c9d2635

@aaribaud aaribaud added the T: bug Something isn't working label Mar 22, 2024
JelleZijlstra pushed a commit that referenced this issue Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant