Python 3 fixes

pull/87/head
Eric Holscher 8 years ago
parent 66fd939395
commit c3db6e5bc8

@ -1,6 +1,5 @@
import sys import sys
import os import os
import re
import textwrap import textwrap
import ast import ast
from collections import defaultdict from collections import defaultdict
@ -174,8 +173,8 @@ class PythonPythonMapper(PythonMapperBase):
# exceptions, including SyntaxError # exceptions, including SyntaxError
try: try:
parsed = ast.parse(source) parsed = ast.parse(source)
except Exception, e: # noqa except Exception as e: # noqa
print "Error parsing AST: %s" % str(e) print("Error parsing AST: %s" % str(e))
return [] return []
parsed_args = parsed.body[0].args parsed_args = parsed.body[0].args
arg_names = [arg.id if sys.version_info < (3,) else arg.arg arg_names = [arg.id if sys.version_info < (3,) else arg.arg

@ -78,8 +78,12 @@ def _get_toc_reference(node, toc, docname):
toc_reference = _find_toc_node(toc, ref_id, nodes.section) toc_reference = _find_toc_node(toc, ref_id, nodes.section)
else: else:
# Desc node # Desc node
ref_id = node.children[0].attributes['ids'][0] try:
toc_reference = _find_toc_node(toc, ref_id, addnodes.desc) ref_id = node.children[0].attributes['ids'][0]
toc_reference = _find_toc_node(toc, ref_id, addnodes.desc)
except IndexError as e:
print('Invalid desc node: %s' % e)
toc_reference = None
return toc_reference return toc_reference
@ -108,8 +112,8 @@ def add_domain_to_toctree(app, doctree, docname):
for desc_node in doctree.traverse(addnodes.desc): for desc_node in doctree.traverse(addnodes.desc):
try: try:
ref_id = desc_node.children[0].attributes['ids'][0] ref_id = desc_node.children[0].attributes['ids'][0]
except IndexError, e: except IndexError as e:
print 'Invalid desc node: %s' % e print('Invalid desc node: %s' % e)
continue continue
try: try:
# Python domain object # Python domain object

Loading…
Cancel
Save