compiler package vs parser

Aahz aahz at pythoncraft.com
Fri Apr 17 15:31:19 CEST 2009


In article <mailman.4042.1239964684.11746.python-list at python.org>,
Robin Becker  <robin at reportlab.com> wrote:
>
>My analysis of the problem is that in
>
>#### start p.py
>def func(D):
>     for k in D:
>         exec '%s=D[%r]' % (k,k)
>     print i, j, k
>     print locals()
>     print i, j, k
>
>if __name__=='__main__':
>     func(dict(i=1,j=33))
>#### end p.py
>
>the compiler package ends up treating i & j as global, whereas the
>modern analysis doesn't (and doesn't say they're definitely local
>either). Looking at the code in Python/compile.c the compile_nameop
>code seems to check for scopes FREE, CELL, LOCAL, GLOBAL_IMPLICIT &
>GLOBAL_EXPLICIT whereas pycodegen.CodeGenerator._nameOp seems not to
>know about GLOBAL_IMPLICIT/EXPLICIT but has only a single GLOBAL scope.

At this point, given the lack of response from people who actually know
the compiler internals, I think it's fair of you to try going to
python-dev -- normally questions like this are off-topic, and if someone
complains, I'll take the blame.  ;-)
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"If you think it's expensive to hire a professional to do the job, wait
until you hire an amateur."  --Red Adair



More information about the Python-list mailing list