The following extension module crashes when passed a non-string argument rather 
than throwing a TypeError:

************* string_bug.pyx *****************
from libcpp.string cimport string

cdef extern from "stdio.h":
   int printf(char *format, ...) nogil

def blow_up(string text):
    printf(text.c_str())

*****************************************

To see this run

************* show_bug.py *****************
import string_bug

# This is O.K.
string_bug.blow_up("Testing...")

# This seg faults for me.
string_bug.blow_up(1)
*****************************************

Here is my setup.py for your convenience:

************** setup.py *******************
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("string_bug",
                             sources=["string_bug.pyx"],
                             language="c++")])
******************************************

Also, I have:

> python
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.

>>> import Cython
>>> Cython.__version__
'0.19.1'

Cheers,
Gerard
This e-mail and any attachments are confidential, may contain legal,
professional or other privileged information, and are intended solely for the
addressee. If you are not the intended recipient, do not use the information
in this e-mail in any way, delete this e-mail and notify the sender. -EXCIP
_______________________________________________
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel

Reply via email to