Cryptic "cythonization" error

78 views
Skip to first unread message

Gabriel Jacobo

unread,
Jul 16, 2012, 6:35:12 PM7/16/12
to cython...@googlegroups.com
I'm getting the following error with the latest Cython compiled from Git while importing a module from outside the tree hierachy (by using the -I parameter)

cython --embed --cplus --include-dir /home/gabo/ignifuga/.. /home/gabo/bunnies/build/linux64/bunniesx.pyx

Traceback (most recent call last):
  File "/usr/local/bin/cython", line 8, in <module>
    main(command_line = 1)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Compiler/Main.py", line 616, in main
    result = compile(sources, options)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Compiler/Main.py", line 591, in compile
    return compile_multiple(source, options)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Compiler/Main.py", line 563, in compile_multiple
    result = run_pipeline(source, options)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Compiler/Main.py", line 426, in run_pipeline
    err, enddata = Pipeline.run_pipeline(pipeline, source)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Compiler/Pipeline.py", line 315, in run_pipeline
    data = phase(data)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Compiler/Pipeline.py", line 31, in parse
    check_module_name = not Options.embed)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Compiler/Main.py", line 168, in find_module
    err, result = self.process_pxd(source_desc, scope, module_name)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Compiler/Main.py", line 100, in process_pxd
    result = Pipeline.run_pipeline(pipeline, source_desc)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Compiler/Pipeline.py", line 315, in run_pipeline
    data = phase(data)
  File "Visitor.py", line 276, in Cython.Compiler.Visitor.CythonTransform.__call__ (/home/gabo/mdqinc/cython/Cython/Compiler/Visitor.c:5567)
  File "Visitor.py", line 259, in Cython.Compiler.Visitor.VisitorTransform.__call__ (/home/gabo/mdqinc/cython/Cython/Compiler/Visitor.c:5295)
  File "Visitor.py", line 165, in Cython.Compiler.Visitor.TreeVisitor._visit (/home/gabo/mdqinc/cython/Cython/Compiler/Visitor.c:3678)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Compiler/ParseTreeTransforms.py", line 1801, in visit_ModuleNode
    node.body.analyse_expressions(node.scope)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Compiler/Nodes.py", line 343, in analyse_expressions
    stat.analyse_expressions(env)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Compiler/Nodes.py", line 6517, in analyse_expressions
    env.use_utility_code(ExprNodes.type_test_utility_code)
AttributeError: 'module' object has no attribute 'type_test_utility_code'


In bunnies.pyx I'm doing...

from ignifuga.backends.sdl.Renderer cimport Renderer, Sprite_p

and this error actually happens if add:

cdef Renderer renderer


In the "global" part of the file (ie, not inside a function or class)

Real bug or am I doing something I'm not supposed to?

-- 
Gabriel.

Sturla Molden

unread,
Jul 16, 2012, 7:22:06 PM7/16/12
to cython...@googlegroups.com
Use the latest stabile Cython release instead.

Sturla

Stefan Behnel

unread,
Jul 17, 2012, 12:26:56 AM7/17/12
to cython...@googlegroups.com
Gabriel Jacobo, 17.07.2012 00:35:
> I'm getting the following error with the latest Cython compiled from Git
> while importing a module from outside the tree hierachy (by using the -I
> parameter)
>
> cython --embed --cplus --include-dir /home/gabo/ignifuga/..
> /home/gabo/bunnies/build/linux64/bunniesx.pyx
>
> Traceback (most recent call last):
> [...]
> File "/usr/local/lib/python2.7/dist-packages/Cython/Compiler/Nodes.py",
> line 6517, in analyse_expressions
> env.use_utility_code(ExprNodes.type_test_utility_code)
> AttributeError: 'module' object has no attribute 'type_test_utility_code'
>
>
> In bunnies.pyx I'm doing...
>
> from ignifuga.backends.sdl.Renderer cimport Renderer, Sprite_p
>
> and this error actually happens if add:
>
> cdef Renderer renderer
>
>
> In the "global" part of the file (ie, not inside a function or class)
>
> Real bug or am I doing something I'm not supposed to?

Thanks for the report. Any compiler crash is always a bug. I pushed a fix.

However, given that this was not detected by our test suite, you could help
us make Cython better by writing a minimal test case that we can add. Using
more than one file for it is fine.

Apparently, you need a star import in your module to trigger this and an
extension type that gets cimported. If both come together, the compiler
should crash without the fix.

Stefan

Gabriel Jacobo

unread,
Jul 17, 2012, 8:11:49 AM7/17/12
to cython...@googlegroups.com
2012/7/17 Stefan Behnel <stef...@behnel.de>


Thanks for the report. Any compiler crash is always a bug. I pushed a fix.

However, given that this was not detected by our test suite, you could help
us make Cython better by writing a minimal test case that we can add. Using
more than one file for it is fine.

Apparently, you need a star import in your module to trigger this and an
extension type that gets cimported. If both come together, the compiler
should crash without the fix.

Stefan


Thanks for the quick fix, it solved the problem, please find attached a minimal test case that should fail with previous versions. It's 3 files, the one that should be tested is star_cimport_test.pyx

--
Gabriel.
star_cimport.py
star_cimport_pxd.pxd
star_cimport_test.pyx

Gabriel Jacobo

unread,
Jul 17, 2012, 8:30:22 AM7/17/12
to cython...@googlegroups.com
2012/7/17 Stefan Behnel <stef...@behnel.de>
I'm attaching another test that may be useful, using a struct pointer to define a STL map fails with "Expected an identifier or literal", but it works with, at least, a deque and if you ctypedef the pointer it works as well.






--
Gabriel.
map_struct_pointer.pyx

Stefan Behnel

unread,
Jul 17, 2012, 9:00:44 AM7/17/12
to cython...@googlegroups.com
Gabriel Jacobo, 17.07.2012 14:11:
> please find attached a
> minimal test case that should fail with previous versions. It's 3 files,
> the one that should be tested is star_cimport_test.pyx

Thanks! I added it here:

https://github.com/cython/cython/commit/03332a1157116d255c48bc256a0264052b8c5a08

Stefan
Reply all
Reply to author
Forward
0 new messages