Skip to content

Commit

Permalink
don't ignore slashes inside strings
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharsadhwani committed Apr 30, 2024
1 parent 9daa7e4 commit 4f91e3b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/blib2to3/pgen2/tokenize.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ def generate_tokens(

# skip lines that are just a slash, to avoid storing that line's
# indent information.
if line.rstrip("\n").strip(" \t") == "\\":
if not contstr and line.rstrip("\n").strip(" \t") == "\\":
continue

pos, max = 0, len(line)
Expand Down
11 changes: 8 additions & 3 deletions tests/data/cases/backslash_before_indent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ class Plotter:

class AnotherCase:
\
pass
"""Some
\
Docstring
"""

# output

Expand All @@ -15,5 +18,7 @@ class Plotter:


class AnotherCase:

pass
"""Some
\
Docstring
"""

0 comments on commit 4f91e3b

Please sign in to comment.