[Cython] BUG: Cython's dies with AttributeError

2011-07-07 Thread Lars Buitinck
Dear developers,

I just got an error message from Cython (current Git). The error can
be reproduced by putting

cdef foo(): pass

in a file called foo.pyx, and compiling that. (I know there's an error
in the file as well.) Would you kindly look into this bug? The error
message was:


foo.pyx:1:9: Compiler crash in PostParse

ModuleNode.body = StatListNode(foo.pyx:1:5)
StatListNode.stats[0] = CFuncDefNode(foo.pyx:1:5,
modifiers = [...]/0,
visibility = u'private')
CFuncDefNode.declarator = CFuncDeclaratorNode(foo.pyx:1:9,
calling_convention = '')
CFuncDeclaratorNode.base = CNameDeclaratorNode(foo.pyx:1:9,
calling_convention = u'',
name = u'foo')

Compiler crash traceback from this point on:
  File "Visitor.py", line 173, in
Cython.Compiler.Visitor.TreeVisitor._visitchild
(/home/s1254871/src/cython/Cython/Compiler/Visitor.c:3550)
  File "Visitor.py", line 282, in
Cython.Compiler.Visitor.CythonTransform.visit_Node
(/home/s1254871/src/cython/Cython/Compiler/Visitor.c:5242)
  File "Visitor.py", line 234, in
Cython.Compiler.Visitor.VisitorTransform.visitchildren
(/home/s1254871/src/cython/Cython/Compiler/Visitor.c:4395)
  File "Visitor.py", line 202, in
Cython.Compiler.Visitor.TreeVisitor._visitchildren
(/home/s1254871/src/cython/Cython/Compiler/Visitor.c:4076)
AttributeError: 'CNameDeclaratorNode' object has no attribute 'base'
foo.pyx:1:9: Compiler crash in PostParse

ModuleNode.body = StatListNode(foo.pyx:1:5)
StatListNode.stats[0] = CFuncDefNode(foo.pyx:1:5,
modifiers = [...]/0,
visibility = u'private')
CFuncDefNode.declarator = CFuncDeclaratorNode(foo.pyx:1:9,
calling_convention = '')
CFuncDeclaratorNode.base = CNameDeclaratorNode(foo.pyx:1:9,
calling_convention = u'',
name = u'foo')

Compiler crash traceback from this point on:
  File "Visitor.py", line 173, in
Cython.Compiler.Visitor.TreeVisitor._visitchild
(/home/s1254871/src/cython/Cython/Compiler/Visitor.c:3550)
  File "Visitor.py", line 282, in
Cython.Compiler.Visitor.CythonTransform.visit_Node
(/home/s1254871/src/cython/Cython/Compiler/Visitor.c:5242)
  File "Visitor.py", line 234, in
Cython.Compiler.Visitor.VisitorTransform.visitchildren
(/home/s1254871/src/cython/Cython/Compiler/Visitor.c:4395)
  File "Visitor.py", line 202, in
Cython.Compiler.Visitor.TreeVisitor._visitchildren
(/home/s1254871/src/cython/Cython/Compiler/Visitor.c:4076)
AttributeError: 'CNameDeclaratorNode' object has no attribute 'base'


-- 
Lars Buitinck
Scientific programmer, ILPS
University of Amsterdam
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Strange cimport behaviour

2011-07-15 Thread Lars Buitinck
2011/7/15 Vitja Makarov :
> I've found strange bug. In my example cimport misses "fcntl.h" include:
>
> ((c2f2e12...)) vitja@vitja-laptop:~/work/cython-vitek/zzz$ cat ./fff.pyx
> cimport posix.unistd
> cimport posix.fcntl
>
> print posix.fcntl.O_RDWR

Fascinating; I can reproduce the error (on Scientific Linux 5.5), but
it goes away when I reverse the order of the includes.

-- 
Lars Buitinck
Scientific programmer, ILPS
University of Amsterdam
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] BUG: Cython's dies with AttributeError

2011-07-19 Thread Lars Buitinck
2011/7/19 Robert Bradshaw :
> On Thu, Jul 7, 2011 at 2:25 PM, Lars Buitinck  wrote:
>> foo.pyx:1:9: Compiler crash in PostParse
>
> I'm unable to reproduce this error, perhaps there's something missing
> in the example here?

I just pulled from your repo and I'm not getting the error message
anymore. Thanks anyway!

-- 
Lars Buitinck
Scientific programmer, ILPS
University of Amsterdam
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Strange cimport behaviour

2011-07-21 Thread Lars Buitinck
2011/7/21 Robert Bradshaw :
> On Wed, Jul 20, 2011 at 10:30 PM, Robert Bradshaw
>  wrote:
>> On Wed, Jul 20, 2011 at 9:40 PM, Vitja Makarov  
>> wrote:
>>> 2011/7/21 Robert Bradshaw :
>>>> I'm not sure what we can do here--we make sure to emit the #include
>>>> statements in the same order as they are encountered in the Cython
>>>> sources because C is sensitive to this kind of thing, but we can't
>>>> really "fix" C. I suppose we could cimport posix.fcntl from within
>>>> posix.unistd to force an ordering.
>
> https://github.com/cython/cython/commit/55d5e576935d83c6bdadc593e36793aecffe0bae

I'm not familiar enough with the Cython internals to understand this
change; are #includes now generated in the C code in the order of the
corresponding cimports?

-- 
Lars Buitinck
Scientific programmer, ILPS
University of Amsterdam
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


[Cython] Bug report: building an extension with --pyrex-gdb fails

2011-12-17 Thread Lars Buitinck
Hello all,

I was trying to build a C++ extension with debugging support as
described in http://docs.cython.org/src/userguide/debugging.html, but
I got an error from the Cython compiler:


lars@schoothond:~/src/sortedcollections$ python setup.py build_ext
--inplace --pyrex-gdb
running build_ext
cythoning sortedcollections/set.pyx to sortedcollections/set.cpp
Traceback (most recent call last):
  File "setup.py", line 9, in 
language="c++")]
  File "/usr/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
  File "/usr/local/lib/python2.7/dist-packages/Cython/Distutils/build_ext.py",
line 125, in run
_build_ext.build_ext.run(self)
  File "/usr/lib/python2.7/distutils/command/build_ext.py", line 340, in run
self.build_extensions()
  File "/usr/local/lib/python2.7/dist-packages/Cython/Distutils/build_ext.py",
line 132, in build_extensions
ext.sources = self.cython_sources(ext.sources, ext)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Distutils/build_ext.py",
line 275, in cython_sources
full_module_name=module_name)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Compiler/Main.py",
line 625, in compile
return compile_single(source, options, full_module_name)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Compiler/Main.py",
line 570, in compile_single
return run_pipeline(source, options, full_module_name)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Compiler/Main.py",
line 462, in run_pipeline
err, enddata = Pipeline.run_pipeline(pipeline, source)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Compiler/Pipeline.py",
line 313, in run_pipeline
data = phase(data)
  File "Visitor.py", line 276, in
Cython.Compiler.Visitor.CythonTransform.__call__
(Cython/Compiler/Visitor.c:5173)
  File "Visitor.py", line 259, in
Cython.Compiler.Visitor.VisitorTransform.__call__
(Cython/Compiler/Visitor.c:4917)
  File "Visitor.py", line 165, in
Cython.Compiler.Visitor.TreeVisitor._visit
(Cython/Compiler/Visitor.c:3401)
  File 
"/usr/local/lib/python2.7/dist-packages/Cython/Compiler/ParseTreeTransforms.py",
line 2613, in visit_ModuleNode
self.visit_FuncDefNode(nested_funcdef)
  File 
"/usr/local/lib/python2.7/dist-packages/Cython/Compiler/ParseTreeTransforms.py",
line 2660, in visit_FuncDefNode
self.tb.start('Function', attrs=attrs)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Debugger/DebugWriter.py",
line 52, in start
self.tb.start(name, attrs or {})
  File "saxparser.pxi", line 398, in lxml.etree.TreeBuilder.start
(src/lxml/lxml.etree.c:83668)
  File "saxparser.pxi", line 430, in
lxml.etree.TreeBuilder._handleSaxStart (src/lxml/lxml.etree.c:84030)
  File "apihelpers.pxi", line 224, in lxml.etree._makeSubElement
(src/lxml/lxml.etree.c:12831)
  File "apihelpers.pxi", line 219, in lxml.etree._makeSubElement
(src/lxml/lxml.etree.c:12756)
  File "apihelpers.pxi", line 299, in lxml.etree._initNodeAttributes
(src/lxml/lxml.etree.c:13615)
  File "apihelpers.pxi", line 1364, in lxml.etree._utf8
(src/lxml/lxml.etree.c:22190)
TypeError: Argument must be bytes or unicode, got 'NoneType'


My setup.py is :


from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

setup(
cmdclass = {'build_ext': build_ext},
ext_modules = [Extension("sortedcollections.set",
 ["sortedcollections/set.pyx"],
 language="c++")]
)


Importing Extension from Cython.Distutils.extension and adding
pyrex_gdb=True to the Extension gives the same error.

Regards,

-- 
Lars Buitinck
Scientific programmer, ILPS
University of Amsterdam
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Bug report: building an extension with --pyrex-gdb fails

2011-12-17 Thread Lars Buitinck
2011/12/17 Lars Buitinck :
> I was trying to build a C++ extension with debugging support as
> described in http://docs.cython.org/src/userguide/debugging.html, but
> I got an error from the Cython compiler:

Forgot to mention: I was using the very latest Git version of Cython,
a04c0f4eccc96ad475360cf3844b5792bd077836.

-- 
Lars Buitinck
Scientific programmer, ILPS
University of Amsterdam
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Bug report: building an extension with --pyrex-gdb fails

2011-12-17 Thread Lars Buitinck
2011/12/17 mark florisson :
> Thanks for your report, could you paste/attach the code of your
> extension module?

The code is online at https://github.com/larsmans/sortedcollection

-- 
Lars Buitinck
Scientific programmer, ILPS
University of Amsterdam
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Bug report: building an extension with --pyrex-gdb fails

2011-12-20 Thread Lars Buitinck
2011/12/17 mark florisson :
> Thanks, that was very helpful. The problem was that generator
> functions apparently don't fill out a name in the symbol table. You
> can try again from this branch:
> https://github.com/markflorisson88/cython/commit/ed648d932f3922f77e140a6292d65f56f4899090
> which will be pushed to cython's master branch later.

It works, thanks!

-- 
Lars Buitinck
Scientific programmer, ILPS
University of Amsterdam
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] errors in C++ tests

2012-07-08 Thread Lars Buitinck
2012/7/8 Stefan Behnel :
> """
> cpp_operators.cpp: In function ‘void __Pyx_CppExn2PyErr()’:
> cpp_operators.cpp:442: error: expected unqualified-id before ‘&’ token
> cpp_operators.cpp:442: error: expected `)' before ‘&’ token
> """
>
> The failing code line is this:
>
> """
>   } catch (const std::bad_alloc& exn) {
> """

Could you check whether the header  is included? It should be to
get the definition of bad_alloc.

-- 
Lars Buitinck
Scientific programmer, ILPS
University of Amsterdam
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] errors in C++ tests

2012-07-08 Thread Lars Buitinck
2012/7/8 Stefan Behnel :
> ... and there also were some more headers missing, so basically, this
> feature never worked. Great. Here's the complete implementation with the
> four header files that I had to add at the top:

I'm pretty sure that at some point, it worked. I implemented this in
6291a2 and the five prior commits, but I did add the appropriate
headers to Cython/Compiler/Nodes.py.

There is a unit test for this feature in tests/run/cpp_exceptions.pyx;
that file includes a header that in turn includes ,  and
, but not  because it doesn't need that to raise
the exception. (It would be more reliable if the test where refactored
into C++ modules so that the headers need not be indirectly included.)

> #include 

Actually, you'll want to include  where std::ios_base is
declared.  is a much "heavier" header.

> Does it make sense to always include these four headers, or should we try
> to handle the exceptions conditionally?

As I said, this should already have been done by
Cython/Compiler/Nodes.py. I'm not sure what's going wrong.

-- 
Lars Buitinck
Scientific programmer, ILPS
University of Amsterdam
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] errors in C++ tests

2012-07-08 Thread Lars Buitinck
2012/7/8 Stefan Behnel :
> Any reason why the env.add_include_file() calls would be better than the
> header inclusion that I implemented right before the function? It's inside
> of the #ifndef block now. After all, they are only needed by that function,
> and when users override it by redefining the name from the outside, they do
> not need to get included. If users include them themselves, they'll be
> included twice - so what.

I'm not really familiar with Cython internals; I just extended
Compiler/Nodes.py that previously added only . I observed
that this leads to the headers being included once, at the top of the
file, which seemed like the clean solution.

Multiple inclusion of C++ standard headers should be completely safe,
but I don't know whether the C++ standard says anything about
including standard headers in the middle of a module.

-- 
Lars Buitinck
Scientific programmer, ILPS
University of Amsterdam
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


[Cython] bug report: compiler crash when assigning from function call returning ndarray

2012-11-19 Thread Lars Buitinck
Hi all,

I just got a compiler crash (Cython 0.17, 0.17.1 and current master)
when trying to compile a call to a function returning an np.ndarray:


cimport numpy as np

cdef np.ndarray[np.float64_t, ndim=2] trivial(X):
return X

def test():
# Uncommenting the following line, or removing the assignment,
# prevents the crash:
#cdef np.ndarray[np.float64_t, ndim=2] Z
Z = trivial(np.zeros(4))


I'm aware that the program contains an error and it's not much of a
hindrance to the project I'm working on, but the error message just
isn't very friendly:


Compiler crash traceback from this point on:
  File "/home/lars/src/cython/Cython/Compiler/ExprNodes.py", line
1528, in analyse_target_types
Buffer.used_buffer_aux_vars(self.entry)
  File "/home/lars/src/cython/Cython/Compiler/Buffer.py", line 280, in
used_buffer_aux_vars
buffer_aux.buflocal_nd_var.used = True
AttributeError: 'NoneType' object has no attribute 'buflocal_nd_var'


More details at https://gist.github.com/4114677. I looked at Buffer.py
and ExprNodes.py, but I couldn't figure out what exactly was going on.
Could someone please look into this?

TIA,

-- 
Lars Buitinck
Scientific programmer, ILPS
University of Amsterdam
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel