|
|
@@ -30,7 +30,7 @@ def findClass(className):
|
|
|
return [classObj, module.__dict__]
|
|
|
return None
|
|
|
|
|
|
-def rebindClass(builtinGlobals, filename):
|
|
|
+def rebindClass(filename):
|
|
|
file = open(filename, 'r')
|
|
|
lines = file.readlines()
|
|
|
for i in xrange(len(lines)):
|
|
|
@@ -101,8 +101,29 @@ def copyFuncs(fromClass, toClass):
|
|
|
# See if we already have a function with this name
|
|
|
oldFunc = toClass.__dict__.get(funcName)
|
|
|
if oldFunc:
|
|
|
+ # 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.
|
|
|
+ newCode = new.code(newFunc.func_code.co_argcount,
|
|
|
+ newFunc.func_code.co_nlocals,
|
|
|
+ newFunc.func_code.co_stacksize,
|
|
|
+ newFunc.func_code.co_flags,
|
|
|
+ newFunc.func_code.co_code,
|
|
|
+ newFunc.func_code.co_consts,
|
|
|
+ newFunc.func_code.co_names,
|
|
|
+ newFunc.func_code.co_varnames,
|
|
|
+ # Use the oldFunc's filename here. Tricky!
|
|
|
+ oldFunc.func_code.co_filename,
|
|
|
+ newFunc.func_code.co_name,
|
|
|
+ newFunc.func_code.co_firstlineno,
|
|
|
+ newFunc.func_code.co_lnotab)
|
|
|
+ newFunc = new.function(newCode,
|
|
|
+ oldFunc.func_globals,
|
|
|
+ oldFunc.func_name,
|
|
|
+ oldFunc.func_defaults)
|
|
|
+ # oldFunc.func_closure)
|
|
|
replaceFuncList.append((oldFunc, funcName, newFunc))
|
|
|
else:
|
|
|
+ # TODO: give these new functions a proper code filename
|
|
|
newFuncList.append((funcName, newFunc))
|
|
|
|
|
|
# Look in the messenger, taskMgr, and other globals that store func
|