Modifying the Python interpreter to create a custom secure version

Gouda Man youdontneedtosendme at
Sun Mar 6 08:32:06 CET 2005

Hey everyone,

I'm embedding the Python interpreter within my program to use as a 
scripting language. However, one of the unique features of our program is 
the ability of the internal language to possess per-object security 
permissions and restricted execution.

Therefore, we need to add extra "magic members" (a la __class__, __doc__, 
and friends) to *all* objects in Python. By editing PyClass_New, we 
managed to add a test member to all old-style classes. Furthermore, by 
editing type_new, we managed to achieve the same results for all user-
made new-style classes.

However! This didn't do anything for built-in types, such as int, object, 

What are we doing wrong, and does anyone have any 
recommendations/experience in modifying the built-in interpreter. The 
source code is clear but a bit daunting when it comes to finding -
exactly- where to place code like this. If we're implementing things too 
far down the type hierarchy, it would be nice to know this beforehand so 
we don't duplicate any code.

Thanks in advance for all your help.

Alex, Lucas
Comp. Engineering
University of Waterloo

More information about the Python-list mailing list