If you copy a code object by calling say new.code with
just the members of an existing code object with
free/cell variables - such as the following nested example:
def null():
return None
def wrapfunc(func):
def _inner(*args):
return func(*args)
return _inner
wrapped = wrapfunc(null)
code_object = wrapped.func_code
new_code_object = new.code(< code_object >)
then the new_code_object will not have had its
free/cell vars removed and will thus not disassemble
correctly. Furthermore
if you create a function out of it, then calling the
function will raise -
SystemError:
R:Python23srcPython-2.3.2Objectscellobject.c:
22: bad argument to internal function
Looking at the code in PyCode_New I can't see why this
should happen.
(Bug noticed on Python 2.3.2 on windows)
|