[Cython] Possible bug in Python string to C++ string conversion

Brunick, Gerard:(Constellation) Gerard.Brunick at constellation.com
Tue Jan 7 00:18:01 CET 2014

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):


To see this run

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

# This is O.K.

# This seg faults for me.

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},

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__

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20140106/30b441a5/attachment.html>

More information about the cython-devel mailing list