Raise PycodeError directly on parsing.

This commit is contained in:
Georg Brandl
2009-01-10 20:34:26 +01:00
parent 646840d387
commit 45c7871448
2 changed files with 6 additions and 1 deletions

View File

@@ -380,6 +380,8 @@ class RstGenerator(object):
# try to also get a source code analyzer for attribute docs
try:
analyzer = ModuleAnalyzer.for_module(mod)
# parse right now, to get PycodeErrors on parsing
analyzer.parse()
except PycodeError, err:
# no source file -- e.g. for builtin and C modules
analyzer = None

View File

@@ -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()