[Python-bugs-list] [ python-Bugs-404774 ] nested scopes segfaults

nobody nobody@sourceforge.net
Tue, 27 Feb 2001 18:41:33 -0800


Bugs #404774, was updated on 2001-02-27 18:24
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=404774&group_id=5470

Category: Python Interpreter Core
Group: None
Status: Closed
Priority: 5
Submitted By: Gregory H. Ball
Assigned to: Nobody/Anonymous
Summary: nested scopes segfaults

Initial Comment:
In current CVS:

If a function was compiled with nested scopes
and with a name resolved in an outer scope, it
expects a cell object in the func_closure slot when
executed.

However the user can legally del f.func_closure.
Core dump follows next time the function is called.

 

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

Comment By: Jeremy Hylton
Date: 2001-02-27 18:41

Message:
Logged In: YES 
user_id=31392

Gregory you are just plain sick <wink>.

I'll make the closure read-only, which is the only sensible
thing to do, particularly since the only reasonable thing
for them to contain is cells and you need C code to make a
cell.


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

Comment By: Gregory H. Ball
Date: 2001-02-27 18:30

Message:
Logged In: YES 
user_id=11365

Here is the testcase:  (import this as a module 
e.g. test_scopes.py, since I'm not sure that from __future__
etc. works interactively yet.)

#test_scopes.py
from __future__ import nested_scopes

def make_closure():
    x=1
    def f():
        print 'x =', x
    return f

f=make_closure()
print f.func_closure
f()
del f.func_closure
print f.func_closure
f()


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

Comment By: Gregory H. Ball
Date: 2001-02-27 18:27

Message:
Logged In: YES 
user_id=11365

I'm trying to upload a test case...

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

Comment By: Gregory H. Ball
Date: 2001-02-27 18:27

Message:
Logged In: YES 
user_id=11365

I'm trying to upload a test case...

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

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=404774&group_id=5470