Commit 4b711c56 authored by Stefan Behnel's avatar Stefan Behnel

include missing utility code when raising StopAsyncIteration

Closes #1692
parent 876a7d33
...@@ -21,6 +21,7 @@ pyexec_globals_utility_code = UtilityCode.load("PyExecGlobals", "Builtins.c") ...@@ -21,6 +21,7 @@ pyexec_globals_utility_code = UtilityCode.load("PyExecGlobals", "Builtins.c")
globals_utility_code = UtilityCode.load("Globals", "Builtins.c") globals_utility_code = UtilityCode.load("Globals", "Builtins.c")
builtin_utility_code = { builtin_utility_code = {
'StopAsyncIteration': UtilityCode.load_cached("StopAsyncIteration", "Coroutine.c"),
} }
...@@ -326,6 +327,7 @@ builtin_types_table = [ ...@@ -326,6 +327,7 @@ builtin_types_table = [
BuiltinMethod("pop", "T", "O", "PySet_Pop")]), BuiltinMethod("pop", "T", "O", "PySet_Pop")]),
("frozenset", "PyFrozenSet_Type", []), ("frozenset", "PyFrozenSet_Type", []),
("Exception", "((PyTypeObject*)PyExc_Exception)[0]", []), ("Exception", "((PyTypeObject*)PyExc_Exception)[0]", []),
("StopAsyncIteration", "((PyTypeObject*)__Pyx_PyExc_StopAsyncIteration)[0]", []),
] ]
...@@ -381,6 +383,8 @@ def init_builtin_types(): ...@@ -381,6 +383,8 @@ def init_builtin_types():
objstruct_cname = None objstruct_cname = None
elif name == 'Exception': elif name == 'Exception':
objstruct_cname = "PyBaseExceptionObject" objstruct_cname = "PyBaseExceptionObject"
elif name == 'StopAsyncIteration':
objstruct_cname = "PyBaseExceptionObject"
else: else:
objstruct_cname = 'Py%sObject' % name.capitalize() objstruct_cname = 'Py%sObject' % name.capitalize()
the_type = builtin_scope.declare_builtin_type(name, cname, utility, objstruct_cname) the_type = builtin_scope.declare_builtin_type(name, cname, utility, objstruct_cname)
...@@ -407,11 +411,6 @@ def init_builtins(): ...@@ -407,11 +411,6 @@ def init_builtins():
'__debug__', PyrexTypes.c_const_type(PyrexTypes.c_bint_type), '__debug__', PyrexTypes.c_const_type(PyrexTypes.c_bint_type),
pos=None, cname='(!Py_OptimizeFlag)', is_cdef=True) pos=None, cname='(!Py_OptimizeFlag)', is_cdef=True)
entry = builtin_scope.declare_var(
'StopAsyncIteration', PyrexTypes.py_object_type,
pos=None, cname='__Pyx_PyExc_StopAsyncIteration')
entry.utility_code = UtilityCode.load_cached("StopAsyncIteration", "Coroutine.c")
global list_type, tuple_type, dict_type, set_type, frozenset_type global list_type, tuple_type, dict_type, set_type, frozenset_type
global bytes_type, str_type, unicode_type, basestring_type, slice_type global bytes_type, str_type, unicode_type, basestring_type, slice_type
global float_type, bool_type, type_type, complex_type, bytearray_type global float_type, bool_type, type_type, complex_type, bytearray_type
......
...@@ -5667,6 +5667,8 @@ class RaiseStatNode(StatNode): ...@@ -5667,6 +5667,8 @@ class RaiseStatNode(StatNode):
if self.exc_type: if self.exc_type:
self.exc_type.generate_evaluation_code(code) self.exc_type.generate_evaluation_code(code)
type_code = self.exc_type.py_result() type_code = self.exc_type.py_result()
if self.exc_type.is_name:
code.globalstate.use_entry_utility_code(self.exc_type.entry)
else: else:
type_code = "0" type_code = "0"
if self.exc_value: if self.exc_value:
......
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