This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [ast branch] fatal error when compiling test_bool.py
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: brett.cannon, jpe
Priority: normal Keywords:

Created on 2005-03-20 00:14 by jpe, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
testast.py jpe, 2005-03-20 00:14 Minimal extract from test_bool.py
symtable.diff jpe, 2005-03-23 01:22
Messages (9)
msg24714 - (view) Author: John Ehresman (jpe) * Date: 2005-03-20 00:14
When using the ast-branch compiler, python exits with a
fatal error when compiling test_bool.py or the
symplified test case that I'll attach.

The immediate problem is that when the compiler is in
make_closure after compiling the lambda, self is found
to be a LOCAL reference type and make_closure assumes
it's a FREE reference if it's not a CELL reference in
the enclosing scope.

I don't know if self is supposed to be a LOCAL
reference or if make_closure should handle LOCAL
references.

msg24715 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2005-03-22 20:34
Logged In: YES 
user_id=357491

An short example of the failure::

 def outer(a):
    def first(): a
    def last(a): pass

This leads to a fatal Python error.  The issue is having a being a local or 
parameter (can make 'a' be 'a = 1' and not a parameter and still have it 
fail), the first closure reference it, and then the second one use it as a 
parameter.
msg24716 - (view) Author: John Ehresman (jpe) * Date: 2005-03-22 21:37
Logged In: YES 
user_id=22785

The issue seems to be that in symtable_analyze, a free
dictionary is created for the entire module and if a name is
found to be free in any function, it is not converted from a
LOCAL to a CELL is any context seen afterwards.  I think the
free variables need to be recorded on a function-by-function
basis.

  
msg24717 - (view) Author: John Ehresman (jpe) * Date: 2005-03-23 01:21
Logged In: YES 
user_id=22785

The attached patch seems to fix this by creating a
dictionary for each scope's free vars and only propagating
up the ones that aren't satisfied by a binding.  With this
and the other patches, the test suite runs w/o segfaulting
up through test_unicode.
msg24718 - (view) Author: John Ehresman (jpe) * Date: 2005-03-23 01:22
Logged In: YES 
user_id=22785

Forgot to add the patch
msg24719 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2005-04-19 05:26
Logged In: YES 
user_id=357491

John, on line 45 of the patch, which becomes line 580 in
Python/symtable.c, you call PyDict_Update() with three
arguments.  Is 'local' supposed to be an argument, or is
'free' the erroneous one?

If I change it so that 'local' is removed then the tests die
on test_unicode (although a ton of other tests fail).
msg24720 - (view) Author: John Ehresman (jpe) * Date: 2005-04-25 01:18
Logged In: YES 
user_id=22785

Yes, it should be PyDict_Update(free, newfree) like it is in
the current CVS.  The unicode failures should be fixed by
compiling and using tokenizer.c rather than
tokenizer_pgen.c, which is mentioned in the comment for
patch 1170272 but didn't get changed when the patch was
applied.  I'm pretty sure tokenizer_pgen.c is not needed.

msg24721 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2005-04-25 02:28
Logged In: YES 
user_id=357491

OK, added a comment in bug #1186345 to this fact.
msg24722 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2005-04-26 03:49
Logged In: YES 
user_id=357491

OK, closed since John verified the version I checked in was
the right way to go.
History
Date User Action Args
2022-04-11 14:56:10adminsetgithub: 41722
2005-03-20 00:14:52jpecreate