Commit d38a5f09 authored by Robert Bradshaw's avatar Robert Bradshaw

Use proper conversion for import star and memory views.

parent dec1d449
......@@ -2051,14 +2051,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
PyrexTypes.typecast(entry.type, py_object_type, "o")))
elif entry.type.create_from_py_utility_code(env):
# if available, utility code was already created in self.prepare_utility_code()
rhs = "%s(o)" % entry.type.from_py_function
if entry.type.is_enum:
rhs = PyrexTypes.typecast(entry.type, PyrexTypes.c_long_type, rhs)
code.putln("%s = %s; if (%s) %s;" % (
entry.cname,
rhs,
entry.type.error_condition(entry.cname),
code.error_goto(entry.pos)))
code.putln(entry.type.from_py_call_code(
'o', entry.cname, entry.pos, code))
else:
code.putln('PyErr_Format(PyExc_TypeError, "Cannot convert Python object %s to %s");' % (
name, entry.type))
......
......@@ -830,6 +830,14 @@ class MemoryViewSliceType(PyrexType):
self.from_py_function = funcname
return True
def from_py_call_code(self, source_code, result_code, error_pos, code,
from_py_function=None, error_condition=None):
return '%s = %s(%s); %s' % (
result_code,
from_py_function or self.from_py_function,
source_code,
code.error_goto_if(error_condition or self.error_condition(result_code), error_pos))
def create_to_py_utility_code(self, env):
self._dtype_to_py_func, self._dtype_from_py_func = self.dtype_object_conversion_funcs(env)
return True
......
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