robertwb / issues-import-test

0 stars 0 forks source link

Potential problems for extern cdefs in argument parsing #54

Open robertwb opened 8 years ago

robertwb commented 8 years ago

Reported by robertwb on 23 Jul 2008 07:57 UTC

Consider this code:

cdef extern from "t.h":
     ctypedef long hullo

def foo(hullo h): pass

I noticed that it creates code like this:
PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "l", __pyx_argnames, 
&__pyx_v_h))

Which could probably destroy the stack if we don't have the exact 
typedef, right? Which means: One should either write our own parsing 
code instead (generate for each parameter signature), or generate the 
typestring at runtime, or insert C checks for the sizeof(the typedefs). 
The latter will destroy the current approach for numpy.int64 and friends 
and remove what I consider a nice feature.

Just as I took all that care to allow approximate typedefs for buffers :-)

Just noting it down, I suppose for now we'll live with it. But need to 
be more careful about recommending approximate typedefs.

-- 
Dag Sverre

See thread at http://codespeak.net/pipermail/cython-dev/2008-July/001760.html

Migrated-From: http://trac.cython.org/ticket/28