Re: Strange interaction between exec, dictionary subtypes, and global variables in 2.4
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: Strange interaction between exec, dictionary subtypes, and global variables in 2.4

From: Alex Martelli <aleax@mail.comcast.net>
Date: Sat Dec 31 2005 - 07:39:18 CET

Crutcher <crutcher@gmail.com> wrote:
   ...
> Except that there is some niggling edge case dealing with variables
> which have been marked 'global'. It seems that if a compiled chunk of
> python contains a 'global VAR' statement, anywhere, then that VAR, and
> only that VAR, will bypass the subclassed functions when it is
> accessed.

As we covered on another mailing list today, the presence of that
'global VAR' anywhere means that accesses to that variable get compiled
into bytecodes LOAD_GLOBAL, STORE_GLOBAL, instead of the LOAD_NAME,
STORE_NAME produced when no 'global VAR' is around; and looking at
ceval.c, we see that the use of dictionary subclasses is only supported
for f_locals -- f_globals (and f_builtins) are always used as 'exact'
dict instances instead. I consider that a bug, even though there might
be a (hopefully miniscule) slowdown in supporting dict subclasses for
f_globals as well as for f_locals. I know you're now working on a patch
for the issue (and I repeat my recommendation of adding a unit-test for
this issue as part of your patch)... let's see what comes up (the
python-dev mailing list may be more appropriate for this discussion,
btw, since it IS about the development of Python).

Alex
Received on Tue Jan 3 03:28:38 2006