]> granicus.if.org Git - python/commit
Fix for SF bug [ #471928 ] global made w/nested list comprehensions
authorJeremy Hylton <jeremy@alum.mit.edu>
Thu, 18 Oct 2001 16:15:10 +0000 (16:15 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Thu, 18 Oct 2001 16:15:10 +0000 (16:15 +0000)
commit961dfe0d854ad28e3258d209210cc4053ebfb866
tree6683af1d16a23ca2255acb7f0a23899a3b40cd73
parentf76de62f7d48a25d5f67357ae7b2f487904a5fcc
Fix for SF bug [ #471928 ] global made w/nested list comprehensions

The symbol table pass didn't have an explicit case for the list_iter
node which is used only for a nested list comprehension.  As a result,
the target of the list comprehension was treated as a use instead of
an assignment.  Fix is to add a case to symtable_node() to handle
list_iter.

Also, rework and document a couple of the subtler implementation
issues in the symbol table pass.  The symtable_node() switch statement
depends on falling through the last several cases, in order to handle
some of the more complicated nodes like atom.  Add a comment
explaining the behavior before the first fall through case.  Add a
comment /* fall through */ at the end of case so that it is explicitly
marked as such.

Move the for_stmt case out of the fall through logic, which simplifies
both for_stmt and default.  (The default used the local variable start
to skip the first three nodes of a for_stmt when it fell through.)

Rename the flag argument to symtable_assign() to def_flag and add a
comment explaining its use:

   The third argument to symatble_assign() is a flag to be passed to
   symtable_add_def() if it is eventually called.  The flag is useful
   to specify the particular type of assignment that should be
   recorded, e.g. an assignment caused by import.
Python/compile.c