Closes #1127: Fix traceback when autodoc tries to tokenize a non-Python file.

This commit is contained in:
Georg Brandl 2013-03-30 14:10:37 +01:00
parent 08839fac68
commit 6feb07951e
2 changed files with 5 additions and 1 deletions

View File

@ -160,6 +160,7 @@ Bugs fixed
width, table layout width and text wrap width. width, table layout width and text wrap width.
* Fix leading space in LaTeX table header cells. * Fix leading space in LaTeX table header cells.
* #1132: Fix LaTeX table output for multi-row cells in the first column. * #1132: Fix LaTeX table output for multi-row cells in the first column.
* #1127: Fix traceback when autodoc tries to tokenize a non-Python file.
* #1126: Fix double-hyphen to en-dash conversion in wrong places such as * #1126: Fix double-hyphen to en-dash conversion in wrong places such as
command-line option names in LaTeX. command-line option names in LaTeX.
* #1117: Handle .pyx files in sphinx-apidoc. * #1117: Handle .pyx files in sphinx-apidoc.

View File

@ -241,7 +241,10 @@ class ModuleAnalyzer(object):
"""Generate tokens from the source.""" """Generate tokens from the source."""
if self.tokens is not None: if self.tokens is not None:
return return
self.tokens = list(tokenize.generate_tokens(self.source.readline)) try:
self.tokens = list(tokenize.generate_tokens(self.source.readline))
except tokenize.TokenError, err:
raise PycodeError('tokenizing failed', err)
self.source.close() self.source.close()
def parse(self): def parse(self):