fixed cell object error, but line numbers are going to be gone again

This commit is contained in:
Joe Shochet 2007-02-16 01:45:38 +00:00
parent dbb484fff5
commit d65a0d2084

View File

@ -101,8 +101,12 @@ def copyFuncs(fromClass, toClass):
# See if we already have a function with this name # See if we already have a function with this name
oldFunc = toClass.__dict__.get(funcName) oldFunc = toClass.__dict__.get(funcName)
if oldFunc: if oldFunc:
"""
# This code is nifty, but with nested functions, give an error:
# SystemError: cellobject.c:22: bad argument to internal function
# Give the new function code the same filename as the old function # Give the new function code the same filename as the old function
# Perhaps there is a cleaner way to do this? This is my best idea. # Perhaps there is a cleaner way to do this? This was my best idea.
newCode = new.code(newFunc.func_code.co_argcount, newCode = new.code(newFunc.func_code.co_argcount,
newFunc.func_code.co_nlocals, newFunc.func_code.co_nlocals,
newFunc.func_code.co_stacksize, newFunc.func_code.co_stacksize,
@ -116,12 +120,12 @@ def copyFuncs(fromClass, toClass):
newFunc.func_code.co_name, newFunc.func_code.co_name,
newFunc.func_code.co_firstlineno, newFunc.func_code.co_firstlineno,
newFunc.func_code.co_lnotab) newFunc.func_code.co_lnotab)
# print 'creating new function:', newFunc.func_code.co_name
newFunc = new.function(newCode, newFunc = new.function(newCode,
oldFunc.func_globals, newFunc.func_globals,
oldFunc.func_name, newFunc.func_name,
oldFunc.func_defaults) newFunc.func_defaults,
# oldFunc.func_closure) newFunc.func_closure)
"""
replaceFuncList.append((oldFunc, funcName, newFunc)) replaceFuncList.append((oldFunc, funcName, newFunc))
else: else:
# TODO: give these new functions a proper code filename # TODO: give these new functions a proper code filename