summaryrefslogtreecommitdiff
path: root/sphinx/pycode/pgen2/tokenize.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-01-10 20:46:13 +0100
committerGeorg Brandl <georg@python.org>2009-01-10 20:46:13 +0100
commit19c1cf1417e05c065cd73a51f8385f8ffe912281 (patch)
tree6b277aae0685e0161a0f5f896fb599d5ffb1d27f /sphinx/pycode/pgen2/tokenize.py
parent8adb54c064568b7e722bd0c8c0a6341738501efa (diff)
parent778631271c3ee71d0e54e6405db1a951f4de4e09 (diff)
downloadsphinx-19c1cf1417e05c065cd73a51f8385f8ffe912281.tar.gz
merge in trunk
Diffstat (limited to 'sphinx/pycode/pgen2/tokenize.py')
-rw-r--r--sphinx/pycode/pgen2/tokenize.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/sphinx/pycode/pgen2/tokenize.py b/sphinx/pycode/pgen2/tokenize.py
index 46ee7842..4489db89 100644
--- a/sphinx/pycode/pgen2/tokenize.py
+++ b/sphinx/pycode/pgen2/tokenize.py
@@ -274,12 +274,17 @@ def generate_tokens(readline):
line = readline()
except StopIteration:
line = ''
+ # if we are not at the end of the file make sure the
+ # line ends with a newline because the parser depends
+ # on that.
+ if line:
+ line = line.rstrip() + '\n'
lnum = lnum + 1
pos, max = 0, len(line)
if contstr: # continued string
if not line:
- raise TokenError, ("EOF in multi-line string", strstart)
+ raise TokenError("EOF in multi-line string", strstart)
endmatch = endprog.match(line)
if endmatch:
pos = end = endmatch.end(0)
@@ -335,7 +340,7 @@ def generate_tokens(readline):
else: # continued statement
if not line:
- raise TokenError, ("EOF in multi-line statement", (lnum, 0))
+ raise TokenError("EOF in multi-line statement", (lnum, 0))
continued = 0
while pos < max: