diff --git a/CHANGES b/CHANGES index 0e4a8a13f..23d72f571 100644 --- a/CHANGES +++ b/CHANGES @@ -160,6 +160,7 @@ Bugs fixed width, table layout width and text wrap width. * Fix leading space in LaTeX table header cells. * #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 command-line option names in LaTeX. * #1117: Handle .pyx files in sphinx-apidoc. diff --git a/sphinx/pycode/__init__.py b/sphinx/pycode/__init__.py index 073c1560d..64999df88 100644 --- a/sphinx/pycode/__init__.py +++ b/sphinx/pycode/__init__.py @@ -241,7 +241,10 @@ class ModuleAnalyzer(object): """Generate tokens from the source.""" if self.tokens is not None: 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() def parse(self):