safer ctype? (was GUIs - A modest Proposal)

Martin v. Loewis martin at v.loewis.de
Sat Jun 12 04:11:59 EDT 2010


> Got me thinking, is it perhaps doable to have a 'safe' ctype that is
> guaranteed to be in the stdlib? Perhaps crippling it in a sense that it
> only allows a known set of functions to be called?

In some sense, a C module wrapping a selected number of functions
(like the win32 extensions) is exactly that.

Notice that it's not (only) the functions itself, but also the 
parameters. It's absolutely easy to crash Python by calling a function 
through ctypes that expects a pointer, and you pass an integer. The
machine code will dereference the pointer (trusting that it actually is 
one), and crash.

Regards,
Martin



More information about the Python-list mailing list