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

Internal error due to second pass mismatch #2068

Closed
javierhonduco opened this issue Mar 26, 2021 · 2 comments
Closed

Internal error due to second pass mismatch #2068

javierhonduco opened this issue Mar 26, 2021 · 2 comments
Labels
C: unstable formatting Formatting changed on the second pass R: duplicate This issue or pull request already exists T: bug Something isn't working

Comments

@javierhonduco
Copy link

Describe the bug

Black fails to format a file due to inconsistent subsequent reformatting (INTERNAL ERROR: Black produced different code on the second pass of the formatter.)

To Reproduce Steps to reproduce the behavior:

~ cat black_repro.py
return calculate_timedelta(
    # comment
    param1, param2
) / datetime.timedelta(days=self._step)
~ black black_repro.py
error: cannot format black_repro.py: INTERNAL ERROR: Black produced different code on the second pass of the formatter.  Please report a bug on https://github.com/psf/black/issues.  This diff might be helpful: /var/folders/20/wmj13sqn4llcdlg29q8dn2xh0000gn/T/blk__vpfxszf.log
Oh no! 💥 💔 💥
1 file failed to reformat.

Environment (please complete the following information):

Repros on Linux:

~ black --version
black.linux, version 20.8b1
➜  ~ python3 --version
Python 3.8.6

and MacOS:

~ black --version
black.macos, version 20.8b1
➜  ~ python3 --version
Python 3.7.5

Does this bug also happen on master? To answer this, you have two options:

repros (black.now.sh is amazing stuff btw, thanks!):

INTERNAL ERROR: Black produced different code on the second pass of the formatter.  Please report a bug on https://github.com/psf/black/issues.  This diff might be helpful: /tmp/blk_swphvz7x.log

Mode(target_versions=set(), line_length=88, string_normalization=True, magic_trailing_comma=True, experimental_string_processing=False, is_pyi=False)
--- source
+++ first pass
@@ -1,4 +1,5 @@
 return calculate_timedelta(
     # comment
-    param1, param2
-) / datetime.timedelta(days=self._step)
\ No newline at end of file
+    param1,
+    param2,
+) / datetime.timedelta(days=self._step)
--- first pass
+++ second pass
@@ -1,5 +1,8 @@
-return calculate_timedelta(
-    # comment
-    param1,
-    param2,
-) / datetime.timedelta(days=self._step)
+return (
+    calculate_timedelta(
+        # comment
+        param1,
+        param2,
+    )
+    / datetime.timedelta(days=self._step)
+)

Additional context
This bug wasn't found as a result of fuzzing or any other testing technique, it was found in our codebase (if you are a FB employee: https://fburl.com/diffusion/9t7h8e06). I just minimised it a bit.

Thanks!!

@javierhonduco javierhonduco added the T: bug Something isn't working label Mar 26, 2021
@javierhonduco
Copy link
Author

Seems like it might be #1629

@ichard26 ichard26 added the C: unstable formatting Formatting changed on the second pass label Mar 29, 2021
@ichard26 ichard26 added the R: duplicate This issue or pull request already exists label Apr 25, 2021
@ichard26
Copy link
Collaborator

Hello!

All reproduction cases in this issue format without error on master. The fixing commit was 8672af3 from PR GH-2126. I'll be marking this issue as a duplicate of GH-1629 since that's what GH-2126 aimed to fix and it's highly likely this issue falls under GH-1629.

Since we use the issue tracker as a reflection of what's on master, I'll be closing this issue. If you have any issues, especially with the new (but stable) output, please open a new issue. Oh and the fix should be available in a published release soon, see GH-2125 for more info.

Thank you for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: unstable formatting Formatting changed on the second pass R: duplicate This issue or pull request already exists T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants