robertwb / issues-import-test

0 stars 0 forks source link

import_star_set() does not generate from_py_function utility code #84

Closed robertwb closed 8 years ago

robertwb commented 8 years ago

Reported by jdemeyer on 12 Jun 2015 14:34 UTC Consider the following files:

header.pxd:

ctypedef struct mytype:
    int foo

cdef mytype broken

cytest.pyx:

# distutils: language = c++

from header cimport broken
from glob import *

Compiling this gives

build/cythonized/sage/misc/cytest.cpp: In function int __pyx_import_star_set(PyObject*, PyObject*, char*):
build/cythonized/sage/misc/cytest.cpp:651:105: error: __pyx_convert__from_py___pyx_t_4sage_4misc_6header_mytype was not declared in this scope
     __pyx_v_4sage_4misc_6header_broken = __pyx_convert__from_py___pyx_t_4sage_4misc_6header_mytype(o); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[__pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L2_error;};

The reason is here in Cython/Compiler/ModuleNode.py:

    def generate_import_star(self, env, code):
[..snip..](0];)
                elif entry.type.from_py_function:
                    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)))
[..snip..]

The problem is that from_py_function() is called but the code for this from_py_function() is not generated.

Migrated-From: http://trac.cython.org/ticket/851

robertwb commented 8 years ago

Comment by scoder on 9 Aug 2015 18:28 UTC Fixed here:

https://github.com/cython/cython/commit/27f8ddb6b2a16d5fe938a42a9655a1919b21161a

robertwb commented 8 years ago

Modified by scoder on 9 Aug 2015 18:28 UTC