[Patches] [ python-Patches-711448 ] Warn about inter-module assignments shadowing builtins

SourceForge.net noreply@sourceforge.net
Wed, 16 Apr 2003 12:01:42 -0700


Patches item #711448, was opened at 2003-03-28 12:12
Message generated for change (Comment added) made by gvanrossum
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=711448&group_id=5470

Category: Core (C code)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Neil Schemenauer (nascheme)
>Assigned to: Neil Schemenauer (nascheme)
Summary: Warn about inter-module assignments shadowing builtins

Initial Comment:
The attached patch modifies module tp_setattro to warn
about
code that adds a name to the globals of another module that
shadows a builtin.  Unfortunately, there are other ways to
modify module globals (e.g. using vars() and mutating the
dictionary).

There are a few issues with module objects that I'm not
clear
about.  For example, do modules always have a md_dict that
is a PyDictObject?

----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2003-04-16 15:01

Message:
Logged In: YES 
user_id=6380

Hm, it's kind of ugly to list all built-in names explicitly;
this list will be out of sync whenever a new built-in is
added. Can't you access the __builtin__ module and use its
keys? (One way to get the __builtin__ module is to use
PySys_GetObject("modules"), which should give you
sys.modules, and take it from there; you can count on
__builtin__ to be there, and if it's not, forget the whole
thing.)

----------------------------------------------------------------------

Comment By: Neil Schemenauer (nascheme)
Date: 2003-03-28 12:15

Message:
Logged In: YES 
user_id=35752

Attaching patch.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=711448&group_id=5470