[Cython] char* and NULL in log statements

Stefan Behnel stefan_ml at behnel.de
Thu Jun 5 08:17:58 CEST 2008


Hi,

Dag Sverre Seljebotn wrote:
> For your purposes, outputting "None" is probably 
> wrong anyway. What happens if the client library passes a char* 
> containing the string "None"? How do you distinguish it?

Yes, that's a valid point (and you're right that Johannes pretty much missed
my point). It would be weird if this worked:

    cdef char* s = NULL
    py_s = s
    assert py_s is None

but this didn't:

    cdef char* s
    py_s = None
    s = py_s

So if both would work, you might really end up with situations where you pass
None into a C function as a NULL pointer. Sounds pretty dangerous to me.

Even if we don't allow the second bit, the first case would already blur the
border between NULL pointers and Python objects, which currently is very well
separated. I think it would be a step backwards to cut into that.

Stefan


More information about the Cython-dev mailing list