mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Raise PycodeError directly on parsing.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user