#NEWLINE# def _set_source( func , new_source ) : #NEWLINE# #INDENT# real_func = _get_real_func ( func ) #NEWLINE# feature_flags = ( real_func . __code__ . co_flags & FEATURE_MASK ) #NEWLINE# localz = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# new_code = compile ( new_source , '<patchy>' , 'exec' , flags = feature_flags , dont_inherit = True ) #NEWLINE# six . exec_ ( new_code , func . __globals__ , localz ) #NEWLINE# new_func = localz [ localz . __name__ ] #NEWLINE# if isinstance ( new_func , ( classmethod , staticmethod ) ) : #NEWLINE# #INDENT# new_code = new_func . __func__ . __code__ #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# new_code = new_func . __code__ #NEWLINE# #UNINDENT# real_func . __code__ = new_code #NEWLINE# _source_map [ real_func ] = new_source