[Python-Dev] Deprecation warning 'assignment shadows builtin' doesn't take __builtins__ into account

Brett C. drifty@alum.berkeley.edu
Mon, 07 Jul 2003 10:44:16 -0700


Troels Therkelsen wrote:
> Hi python-dev,
> 
> I noticed this behaviour:
> 
> Python 2.3b2 (#1, Jun 30 2003, 13:04:39) 
> [GCC 2.95.3 20010315 (release)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> 
>>>>import sys, new
>>>>d = {'__builtins__':{}}
>>>>d['mod'] = new.module('mod')
>>>>d['mod'].__builtins__ = d['__builtins__']
>>>>exec "mod.reload = 42" in d
> 
> <string>:1: DeprecationWarning: assignment shadows builtin
> 
>>>>d['sys'] = sys
>>>>exec "print sys._getframe().f_builtins" in d
> 
> {}
> 
> Surely, the DeprecationWarning shouldn't be printed if you use
> __builtins__ to explicitly define your own builtins dict?  I mean,
> the 'reload' name in this case is an unknown name until it is
> defined in mod.
<SNIP>
> 
> Sorry for the long post, feel free to flog me with a wet fish ;-)
> 

Trust me, Troels, there have been *much* longer.  And the only reason 
anyone would want to flog you with an aquatic animal is because you 
attached the patch to the email instead of creating a SourceForge patch 
item at http://sourceforge.net/tracker/?group_id=5470&atid=305470 .  If 
you could do that it would be really appreciated since doing changes to 
the patch can be tracked more easily.

-Brett