"Ian Bicking" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > The func_code attributes of functions is writable, but I don't know how > to create the proper code object. Just compiling a new body isn't good > enough.
Did you directly compile the body or compile a function and then extract the code object? In any case, if you need to patch the code object and cannot do so directly due to read-only fields, this may help: >>> import new >>> dir(new) ['__builtins__', '__doc__', '__file__', '__name__', 'classobj', 'code', 'function', 'instance', 'instancemethod', 'module'] >>> help(new.code) Help on class code in module __builtin__: class code(object) | code(argcount, nlocals, stacksize, flags, codestring, constants, names, | varnames, filename, name, firstlineno, lnotab[, freevars[, cellvars]]) | | Create a code object. Not for the faint of heart. | | Methods defined here: ... Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list