summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-10-15 01:49:37 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-10-15 01:49:37 (GMT)
commit447dc1565826c879faf544cda4bdd62546545166 (patch)
tree997fbd5b448d05eabb1d16617bce73dcae6e2922 /Lib
parente537adfd080ffe57e9f202a931cf70e22213e8a4 (diff)
downloadcpython-447dc1565826c879faf544cda4bdd62546545166.zip
cpython-447dc1565826c879faf544cda4bdd62546545166.tar.gz
cpython-447dc1565826c879faf544cda4bdd62546545166.tar.bz2
use floor division and add a test that exercises the tabsize codepath
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_tokenize.py17
-rw-r--r--Lib/tokenize.py2
2 files changed, 18 insertions, 1 deletions
diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py
index ae5f410..e5371cf 100644
--- a/Lib/test/test_tokenize.py
+++ b/Lib/test/test_tokenize.py
@@ -508,6 +508,23 @@ pass the '-ucompiler' option to process the full directory.
... break
... else: True
True
+
+Evil tabs
+ >>> dump_tokens("def f():\\n\\tif x\\n \tpass")
+ NAME 'def' (1, 0) (1, 3)
+ NAME 'f' (1, 4) (1, 5)
+ OP '(' (1, 5) (1, 6)
+ OP ')' (1, 6) (1, 7)
+ OP ':' (1, 7) (1, 8)
+ NEWLINE '\\n' (1, 8) (1, 9)
+ INDENT '\\t' (2, 0) (2, 1)
+ NAME 'if' (2, 1) (2, 3)
+ NAME 'x' (2, 4) (2, 5)
+ NEWLINE '\\n' (2, 5) (2, 6)
+ INDENT ' ' (3, 0) (3, 9)
+ NAME 'pass' (3, 9) (3, 13)
+ DEDENT '' (4, 0) (4, 0)
+ DEDENT '' (4, 0) (4, 0)
"""
diff --git a/Lib/tokenize.py b/Lib/tokenize.py
index ad3cf9d..686ad66 100644
--- a/Lib/tokenize.py
+++ b/Lib/tokenize.py
@@ -319,7 +319,7 @@ def generate_tokens(readline):
if line[pos] == ' ':
column = column + 1
elif line[pos] == '\t':
- column = (column/tabsize + 1)*tabsize
+ column = (column//tabsize + 1)*tabsize
elif line[pos] == '\f':
column = 0
else: