[Python-Dev] DeprecationWarning: assignment shadows builtin

Guido van Rossum guido@python.org
Wed, 16 Jul 2003 16:43:44 -0400


> Ralf W. Grosse-Kunstleve wrote:
> > >>> import std_vector
> > __main__:1: DeprecationWarning: assignment shadows builtin
> > >>> dir(std_vector)
> > ['__doc__', '__file__', '__name__', 'array_cast', 'boost_array_sum',
> > 'cos', 'double', 'float', 'in_place_multiply', 'int', 'long', 'size_t']
> > 
> > std_vector is a Boost.Python extension module

[Neil]
> I suspect the warning is shown due to the way Boost builds the namespace
> of the extension module.  Shadowing of builtin names is checked by the
> setattr method of the module type.  Boost is probably using
> module_setattr to populate the global dictionary.  There's nothing wrong
> with doing that except that it triggers a spurious warning.

But this is yet another situation where this warning is issued but it
really shouldn't be issued.  I'm beginning to think that perhaps we
should make it a PendingDeprecationWarning instead?  That should be
simple even this close to the 2.3c1 release.

--Guido van Rossum (home page: http://www.python.org/~guido/)