[Cython] Fwd: MemoryView.is_f_contig sometimes not defined?

2013-02-09 Thread David Hirschfeld
Reposting because I think my original got blocked because of
attachments. Apologies if this appears twice.

I want to allow arbitrary C/F contiguous arrays as input to a cdef
class so I can dispatch to a different calculation method in each
case, avoiding a potentially costly copy.
Unfortunately, it appears that cython is generating incorrect code.
The following minimal example reproduces the problem:

cimport cython

cdef class TestContig:

cdef cython.bint contig

def __init__(self, double[:,:] y):
if y.is_c_contig():
self.contig = 1
elif y.is_f_contig():
self.contig = 1
else:
self.contig = 0

property contig:
def __get__(self):
return self.contig

#


C:\temp> python setup.py build_ext --inplace
running build_ext
building 'example' extension
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\cl.exe /c
/nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\dev\bin\Python27\include
-IC:\dev\bin\Python27\PC /Tpexample.cpp
/Fobuild\temp.win32-2.7\Release\example.obj
example.cpp
example.cpp(1277) : error C3861: '__pyx_memviewslice_is_f_contig2':
identifier not found
error: command '"C:\Program Files (x86)\Microsoft Visual Studio
11.0\VC\BIN\cl.exe"' failed with exit status 2
C:\temp>


I'm on Windows7 with 32bit Python2.7 and I tested that compilation
fails with both VS2012 & MinGW32 4.6.1.

NB: If you only check for f-contiguity (or c-contiguity) in the method it
compiles fine, it appears that the bug only appears when you test for
both f and c contiguity in the same method.


Thanks,
Dave
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] -O3 causes MinGW to segfault python

2013-04-29 Thread David Hirschfeld
Forwarded because attachments were too large. The source files and
generated .c file can now be viewed at:
https://gist.github.com/dhirschfeld/5480711


Is this a bug or is the recommendation to not build with -O3?
>
> Build log, segfault and version info below.
> Input files and generated .c file attached.
>
> C:\temp> python setup.py build_ext --inplace --force
> running build_ext
> cythoning test_o3.pyx to test_o3.c
> building 'test_o3' extension
> C:\dev\bin\MinGW32\bin\gcc.exe -march=native -mdll -O3 -Wall
> -IC:\dev\bin\Python27\include -IC:\dev\bin\Python27\PC
> -c test_o3.c -o build\temp.win32-2.7\Release\test_o3.o
> test_o3.c: In function '__Pyx_RaiseArgtupleInvalid':
> test_o3.c:1002:18: warning: unknown conversion type character 'z' in
> format [-Wformat]
> test_o3.c:1002:18: warning: format '%s' expects argument of type 'char *',
> but argument 5 has type 'Py_ssize_t' [-Wformat]
> test_o3.c:1002:18: warning: unknown conversion type character 'z' in
> format [-Wformat]
> test_o3.c:1002:18: warning: too many arguments for format
> [-Wformat-extra-args]
> writing build\temp.win32-2.7\Release\test_o3.def
> C:\dev\bin\MinGW32\bin\gcc.exe -march=native -shared -s
> build\temp.win32-2.7\Release\test_o3.o
> build\temp.win32-2.7\Release\test_o3.def
> -LC:\dev\bin\Python27\libs -LC:\dev\bin\Python27\PCbuild -lpython27
> -lmsvcr90 -o
> C:\temp\test_o3.pyd
>
> C:\temp> python
> Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]
> on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import Cython; Cython.__version__
> '0.19'
> >>> import faulthandler; faulthandler.enable()
> >>> from test_o3 import f
> >>> f(1., 2., 3., 4.)
> Fatal Python error: Segmentation fault
>
> Current thread 0x1c38:
>   File "", line 1 in 
>
> C:\temp> gcc --version
> gcc.exe (tdm-1) 4.7.1
> Copyright (C) 2012 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> Thanks,
> Dave
>
>
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel