summaryrefslogtreecommitdiff
path: root/sphinx/pycode
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-01-10 20:35:16 +0100
committerGeorg Brandl <georg@python.org>2009-01-10 20:35:16 +0100
commit778631271c3ee71d0e54e6405db1a951f4de4e09 (patch)
tree86f26d5b65c054047beab5800f2d87c8c7e8aa7f /sphinx/pycode
parentd103698d5f6f687094983f678df80c41aac4fac3 (diff)
parent383cfe40faf164d76eb75bb1c543e52fa9f28397 (diff)
downloadsphinx-778631271c3ee71d0e54e6405db1a951f4de4e09.tar.gz
merge in Ben's bundle with more py3k compatibility
Diffstat (limited to 'sphinx/pycode')
-rw-r--r--sphinx/pycode/__init__.py5
-rw-r--r--sphinx/pycode/pgen2/tokenize.py5
2 files changed, 9 insertions, 1 deletions
diff --git a/sphinx/pycode/__init__.py b/sphinx/pycode/__init__.py
index 17dc6afb..c2086da5 100644
--- a/sphinx/pycode/__init__.py
+++ b/sphinx/pycode/__init__.py
@@ -210,7 +210,10 @@ class ModuleAnalyzer(object):
if self.parsetree is not None:
return
self.tokenize()
- self.parsetree = pydriver.parse_tokens(self.tokens)
+ try:
+ self.parsetree = pydriver.parse_tokens(self.tokens)
+ except parse.ParseError, err:
+ raise PycodeError('parsing failed', err)
# find the source code encoding
encoding = sys.getdefaultencoding()
comments = self.parsetree.get_prefix()
diff --git a/sphinx/pycode/pgen2/tokenize.py b/sphinx/pycode/pgen2/tokenize.py
index 3a0478e0..4489db89 100644
--- a/sphinx/pycode/pgen2/tokenize.py
+++ b/sphinx/pycode/pgen2/tokenize.py
@@ -274,6 +274,11 @@ 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)