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

Python counting is wrong with "" or '' #379

Open
geohot opened this issue Mar 1, 2023 · 1 comment
Open

Python counting is wrong with "" or '' #379

geohot opened this issue Mar 1, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@geohot
Copy link

geohot commented Mar 1, 2023

Describe the bug
Python parser gets stuck in string state if it sees '' or ""

To Reproduce

Create tmp.py with this content and run scc tmp.py

a = ''

# comment
for i in range(10):
  print(i)

Expected behavior

This is the (wrong) output

───────────────────────────────────────────────────────────────────────────────
Language                 Files     Lines   Blanks  Comments     Code Complexity
───────────────────────────────────────────────────────────────────────────────
Python                       1         6        0         0        6          0
───────────────────────────────────────────────────────────────────────────────
Total                        1         6        0         0        6          0
───────────────────────────────────────────────────────────────────────────────

You get this if you change '' to str()

───────────────────────────────────────────────────────────────────────────────
Language                 Files     Lines   Blanks  Comments     Code Complexity
───────────────────────────────────────────────────────────────────────────────
Python                       1         6        2         1        3          1
───────────────────────────────────────────────────────────────────────────────
Total                        1         6        2         1        3          1
───────────────────────────────────────────────────────────────────────────────

Desktop (please complete the following information):
Mac OS, tried version in brew and master

@boyter boyter added the bug Something isn't working label Mar 2, 2023
@boyter
Copy link
Owner

boyter commented Mar 2, 2023

That's an interesting one!

@boyter boyter added this to ToDo in Release 3.2.0 Nov 27, 2023
samhocevar added a commit to samhocevar/challenges that referenced this issue Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Development

No branches or pull requests

2 participants