string to type object (C)

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Aug 12 07:37:07 CEST 2008


En Wed, 06 Aug 2008 01:55:10 -0300, castironpi <castironpi at gmail.com>  
escribi�:

> Do you know if uncooperative (not necc'ly malicious) code could
> interfere:
>
>>>> __builtin__.int= None
>>>> __builtin__.int
>>>> __builtin__.int= type( 0 )
>>>> __builtin__.int
> <type 'int'>
>
> ?  Or would PyImport_Import(s) create a namespace that had the int
> type in it from scratch?

Once you modify __builtin__, any later access to builtin names will see  
the changed values.
I don't know of any way to "reset" the builtin module - other than calling  
again _PyBuiltin_Init from C code.

-- 
Gabriel Genellina




More information about the Python-list mailing list