mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #5019: autodoc: crashed by Form Feed Character
This commit is contained in:
parent
ac9f973c9b
commit
0edcae1ff8
1
CHANGES
1
CHANGES
@ -26,6 +26,7 @@ Bugs fixed
|
|||||||
* C++, fix lookup of full template specializations with no template arguments.
|
* C++, fix lookup of full template specializations with no template arguments.
|
||||||
* #4667: C++, fix assertion on missing references in global scope when using
|
* #4667: C++, fix assertion on missing references in global scope when using
|
||||||
intersphinx. Thanks to Alan M. Carroll.
|
intersphinx. Thanks to Alan M. Carroll.
|
||||||
|
* #5019: autodoc: crashed by Form Feed Character
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -34,6 +34,11 @@ else:
|
|||||||
ASSIGN_NODES = (ast.Assign)
|
ASSIGN_NODES = (ast.Assign)
|
||||||
|
|
||||||
|
|
||||||
|
def filter_whitespace(code):
|
||||||
|
# type: (unicode) -> unicode
|
||||||
|
return code.replace('\f', ' ') # replace FF (form feed) with whitespace
|
||||||
|
|
||||||
|
|
||||||
def get_assign_targets(node):
|
def get_assign_targets(node):
|
||||||
# type: (ast.AST) -> List[ast.expr]
|
# type: (ast.AST) -> List[ast.expr]
|
||||||
"""Get list of targets from Assign and AnnAssign node."""
|
"""Get list of targets from Assign and AnnAssign node."""
|
||||||
@ -466,7 +471,7 @@ class Parser(object):
|
|||||||
|
|
||||||
def __init__(self, code, encoding='utf-8'):
|
def __init__(self, code, encoding='utf-8'):
|
||||||
# type: (unicode, unicode) -> None
|
# type: (unicode, unicode) -> None
|
||||||
self.code = code
|
self.code = filter_whitespace(code)
|
||||||
self.encoding = encoding
|
self.encoding = encoding
|
||||||
self.comments = {} # type: Dict[Tuple[unicode, unicode], unicode]
|
self.comments = {} # type: Dict[Tuple[unicode, unicode], unicode]
|
||||||
self.deforders = {} # type: Dict[unicode, int]
|
self.deforders = {} # type: Dict[unicode, int]
|
||||||
|
@ -315,3 +315,12 @@ def test_decorators():
|
|||||||
'func3': ('def', 7, 9),
|
'func3': ('def', 7, 9),
|
||||||
'Foo': ('class', 11, 15),
|
'Foo': ('class', 11, 15),
|
||||||
'Foo.method': ('def', 13, 15)}
|
'Foo.method': ('def', 13, 15)}
|
||||||
|
|
||||||
|
|
||||||
|
def test_formfeed_char():
|
||||||
|
source = ('class Foo:\n'
|
||||||
|
'\f\n'
|
||||||
|
' attr = 1234 #: comment\n')
|
||||||
|
parser = Parser(source)
|
||||||
|
parser.parse()
|
||||||
|
assert parser.comments == {('Foo', 'attr'): 'comment'}
|
||||||
|
Loading…
Reference in New Issue
Block a user