[Python-Dev] object capability; func_closure; __subclasses__

Phillip J. Eby pje at telecommunity.com
Thu Jun 28 19:44:03 CEST 2007


At 01:26 PM 6/28/2007 -0400, Phillip J. Eby wrote:
>You should also be able to delete unwanted function type attributes 
>like this::
>
>    from types import FunctionType
>    del dictionary_of(FunctionType)['func_closure']
>    del dictionary_of(FunctionType)['func_code']

By the way, you probably want to also delete func_globals and 
func_defaults, as there are security ramifications to those 
attributes as well.  Probably not so much for func_dict/__dict__ though.

And of course, for Python<=2.4 you can just use the __call__ 
attribute and not bother with deleting anything but __subclasses__.



More information about the Python-Dev mailing list