[C++-SIG] Python calling C++ issues
David Beazley
beazley at cs.uchicago.edu
Wed Dec 1 15:22:44 CET 1999
Duncan Grisby writes:
>
> I haven't particularly followed the discussion, but I just want to
> point out that doing what you suggest is extremely dangerous. There is
> no guarantee that longs are the same size as pointers.
With the notable exception of pointers to members, since when has a
long never been large enough to hold a pointer value? Can you name a
specific instance where this doesn't work? (or has the C++ standards
committee finally decided to break all pointers just for the hell of
it?) SWIG does this internally and has never had any problems.
> There is also
> nothing to stop the Python code from modifying the integer, causing
> the C code to dereference arbitrary memory locations. It shouldn't be
> possible for Python code to cause core dumps. You should use
> PyCObjects instead.
Just because you use a CObject doesn't mean you're going to eliminate
core dumps. Of course, I personally believe that you should be able
to modify the pointer value if you really want to--but that's just me :-).
Cheers,
Dave
More information about the Cplusplus-sig
mailing list