def _FixCodeFilename(code, filename):
 if isinstance(code, types.CodeType):
  code = types.CodeType(code.co_argcount, code.co_nlocals, code.co_stacksize, code.co_flags, code.co_code, tuple([_FixCodeFilename(c, filename) for c in code.co_consts]), code.co_names, code.co_varnames, filename, code.co_name, code.co_firstlineno, code.co_lnotab, code.co_freevars, code.co_cellvars)
 return code

def _FixCodeFilename ( code , filename ) : if isinstance ( code , types . CodeType ) : code = types . CodeType ( code . co_argcount , code . co_nlocals , code . co_stacksize , code . co_flags , code . co_code , tuple ( [ _FixCodeFilename ( c , filename ) for c in code . co_consts ] ) , code . co_names , code . co_varnames , filename , code . co_name , code . co_firstlineno , code . co_lnotab , code . co_freevars , code . co_cellvars ) return code
creates a codetype with co_filename replaced with filename .