Commit ce98ed57 authored by Stefan Behnel's avatar Stefan Behnel

prevent plain annotation type parsing from erroring out on unparsable annotations

parent c31b0fad
...@@ -1179,11 +1179,13 @@ def _analyse_name_as_type(name, pos, env): ...@@ -1179,11 +1179,13 @@ def _analyse_name_as_type(name, pos, env):
type = PyrexTypes.parse_basic_type(name) type = PyrexTypes.parse_basic_type(name)
if type is not None: if type is not None:
return type return type
hold_errors()
from TreeFragment import TreeFragment from TreeFragment import TreeFragment
pos = (pos[0], pos[1], pos[2]-7) pos = (pos[0], pos[1], pos[2]-7)
declaration = TreeFragment(u"sizeof(%s)" % name, name=pos[0].filename, initial_pos=pos) declaration = TreeFragment(u"sizeof(%s)" % name, name=pos[0].filename, initial_pos=pos)
sizeof_node = declaration.root.stats[0].expr sizeof_node = declaration.root.stats[0].expr
sizeof_node = sizeof_node.analyse_types(env) sizeof_node = sizeof_node.analyse_types(env)
release_errors(ignore=True)
if isinstance(sizeof_node, SizeofTypeNode): if isinstance(sizeof_node, SizeofTypeNode):
return sizeof_node.arg_type return sizeof_node.arg_type
return None return None
......
...@@ -839,7 +839,7 @@ class CArgDeclNode(Node): ...@@ -839,7 +839,7 @@ class CArgDeclNode(Node):
def inject_type_from_annotations(self, env): def inject_type_from_annotations(self, env):
annotation = self.annotation annotation = self.annotation
if not annotation: if not annotation:
return return None
explicit_pytype = explicit_ctype = False explicit_pytype = explicit_ctype = False
if annotation.is_dict_literal: if annotation.is_dict_literal:
for name, value in annotation.key_value_pairs: for name, value in annotation.key_value_pairs:
...@@ -1569,6 +1569,8 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -1569,6 +1569,8 @@ class FuncDefNode(StatNode, BlockNode):
elif isinstance(arg, CArgDeclNode) and arg.annotation: elif isinstance(arg, CArgDeclNode) and arg.annotation:
type_node = arg.annotation type_node = arg.annotation
other_type = arg.inject_type_from_annotations(env) other_type = arg.inject_type_from_annotations(env)
if other_type is None:
return arg
else: else:
return arg return arg
if other_type is None: if other_type is None:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment