Skip to content

Commit

Permalink
tokenizer: skip lines that are just whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharsadhwani committed Apr 30, 2024
1 parent f2da85f commit 19cc96b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/blib2to3/pgen2/tokenize.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,12 @@ def generate_tokens(
except StopIteration:
line = ""
lnum += 1

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

pos, max = 0, len(line)

if contstr: # continued string
Expand Down
18 changes: 18 additions & 0 deletions tests/data/cases/backslash_before_indent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Plotter:
\
pass

class AnotherCase:
\
pass

# output

class Plotter:

pass


class AnotherCase:

pass

0 comments on commit 19cc96b

Please sign in to comment.