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

Short code generates INTERNAL ERROR on second pass #2102

Closed
ochtersk opened this issue Apr 12, 2021 · 1 comment
Closed

Short code generates INTERNAL ERROR on second pass #2102

ochtersk opened this issue Apr 12, 2021 · 1 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

Comments

@ochtersk
Copy link

Describe the bug code generates INTERNAL ERROR: Black produced different code on the second pass of the formatter.

To Reproduce Steps to reproduce the behavior:

Enter this code:
class SciSigFig:
def dump(self):
numstr = str(self)
return ' xxxnumber:%s\n str(number):%s\n sfcode:%s\n sfid:%s\n sfcount:%s\n uexp:%s\n notation:%s' %
(self.number,numstr, self.sfcode,self.sfid,self.sfcount,self.uexp,self.notation)

into Black playground https://black.vercel.app/ (accessed 11:40 EDT 04-12-2021)

** Error message:**
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_6fjvz6ci.log

Mode(target_versions=set(), line_length=88, string_normalization=True, experimental_string_processing=False, is_pyi=False)
--- source
+++ first pass
@@ -1,6 +1,15 @@
class SciSigFig:
def dump(self):
numstr = str(self)

  •    return '  xxxnumber:%s\n str(number):%s\n      sfcode:%s\n        sfid:%s\n     sfcount:%s\n        uexp:%s\n    notation:%s' % \
    
  •        (self.number,numstr, self.sfcode,self.sfid,self.sfcount,self.uexp,self.notation)
    
  •    return (
    
  •        "  xxxnumber:%s\n str(number):%s\n      sfcode:%s\n        sfid:%s\n     sfcount:%s\n        uexp:%s\n    notation:%s"
    
  •        % (
    
  •            self.number,
    
  •            numstr,
    
  •            self.sfcode,
    
  •            self.sfid,
    
  •            self.sfcount,
    
  •            self.uexp,
    
  •            self.notation,
    
  •        )
    
  •    )
    

--- first pass
+++ second pass
@@ -1,15 +1,12 @@
class SciSigFig:
def dump(self):
numstr = str(self)

  •    return (
    
  •        "  xxxnumber:%s\n str(number):%s\n      sfcode:%s\n        sfid:%s\n     sfcount:%s\n        uexp:%s\n    notation:%s"
    
  •        % (
    
  •            self.number,
    
  •            numstr,
    
  •            self.sfcode,
    
  •            self.sfid,
    
  •            self.sfcount,
    
  •            self.uexp,
    
  •            self.notation,
    
  •        )
    
  •    return "  xxxnumber:%s\n str(number):%s\n      sfcode:%s\n        sfid:%s\n     sfcount:%s\n        uexp:%s\n    notation:%s" % (
    
  •        self.number,
    
  •        numstr,
    
  •        self.sfcode,
    
  •        self.sfid,
    
  •        self.sfcount,
    
  •        self.uexp,
    
  •        self.notation,
       )
    

Expected behavior A clear and concise description of what you expected to happen.

Expected reformatted code

Environment (please complete the following information):

  • Version: [e.g. master]
  • OS and Python version: [e.g. Linux/Python 3.7.4rc1]

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

  1. Use the online formatter at https://black.now.sh/?version=master, which will use the
    latest master branch.

Yes, it occurs on the master

@ochtersk ochtersk added the T: bug Something isn't working label Apr 12, 2021
@ichard26 ichard26 added the C: unstable formatting Formatting changed on the second pass label Apr 12, 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!

@ichard26 ichard26 added the R: duplicate This issue or pull request already exists label Apr 25, 2021
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