[Python-bugs-list] [ python-Bugs-492403 ] exec() segfaults on closure's func_code

noreply@sourceforge.net noreply@sourceforge.net
Thu, 13 Dec 2001 01:34:12 -0800


Bugs item #492403, was opened at 2001-12-13 01:33
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=492403&group_id=5470

Category: Python Interpreter Core
Group: Python 2.1.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Danny Yoo (dyoo)
Assigned to: Nobody/Anonymous (nobody)
Summary: exec() segfaults on closure's func_code

Initial Comment:
I was experimenting with func_code, and the
documentation in:

http://python.org/doc/current/lib/bltin-code-objects.html

made me curious to see what would happen if I tried to
exec() a closure's func_code.  This produces a segfault
under Python 2.1, 2.11, and 2.2b:

###
>>> from __future__ import nested_scopes
>>> def t1(n):
...     def t2(): return n
...     return t2
... 
>>> f = t1(5)
>>> f.func_code
<code object t2 at 0x810e5e0, file "<stdin>", line 2>
>>> exec(f.func_code)
Segmentation fault
###

This code also crashes if run as a program, so it's not
just in the interactive interpreter.  I've included a
"crash.py" file that reproduces the bug.


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

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