<s> """<STR_LIT>""" <EOL> import base64 <EOL> import logging <EOL> import sys <EOL> import traceback <EOL> import types <EOL> import dill <EOL> def is_nested_class ( cls ) : <EOL> """<STR_LIT>""" <EOL> return ( isinstance ( cls , type ) <EOL> and cls . __module__ != '<STR_LIT>' <EOL> and cls . __name__ not in sys . modules [ cls . __module__ ] . __dict__ ) <EOL> def find_containing_class ( nested_class ) : <EOL> """<STR_LIT>""" <EOL> def find_containing_class_inner ( outer ) : <EOL> for k , v in outer . __dict__ . items ( ) : <EOL> if v is nested_class : <EOL> return outer , k <EOL> elif isinstance ( v , ( type , types . ClassType ) ) and hasattr ( v , '<STR_LIT>' ) : <EOL> res = find_containing_class_inner ( v ) <EOL> if res : return res <EOL> return find_containing_class_inner ( sys . modules [ nested_class . __module__ ] ) <EOL> def _nested_type_wrapper ( fun ) : <EOL> """<STR_LIT>""" <EOL> def wrapper ( pickler , obj ) : <EOL> if is_nested_class ( obj ) and obj . __module__ != '<STR_LIT:__main__>' : <EOL> containing_class_and_name = find_containing_class ( obj ) <EOL> if containing_class_and_name is not None : <EOL> return pickler . save_reduce ( <EOL> getattr , containing_class_and_name , obj = obj ) <EOL> try : <EOL> return fun ( pickler , obj ) <EOL> except dill . dill . PicklingError : <EOL> return pickler . save_reduce ( <EOL> dill . dill . _create_type , <EOL> ( type ( obj ) , obj . __name__ , obj . __bases__ , <EOL> dill . dill . _dict_from_dictproxy ( obj . __dict__ ) ) , <EOL> obj = obj ) <EOL> return wrapper <EOL> dill . dill . Pickler . dispatch [ type ] = _nested_type_wrapper ( <EOL> dill . dill . Pickler . dispatch [ type ] ) <EOL> def reject_generators ( unused_pickler , unused_obj ) : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> dill . dill . Pickler . dispatch [ types . GeneratorType ] = reject_generators <EOL> if '<STR_LIT>' in dir ( dill . dill ) : <EOL> old_save_module = dill . dill . save_module <EOL> @ dill . dill . register ( dill . dill . ModuleType ) <EOL> def save_module ( pickler , obj ) : <EOL> if dill . dill . is_dill ( pickler ) and obj is pickler . _main : <EOL> return old_save_module ( pickler , obj ) <EOL> else : <EOL> dill . dill . log . info ( '<STR_LIT>' % obj ) <EOL> pickler . save_reduce ( dill . dill . _import_module , ( obj . __name__ , ) , obj = obj ) <EOL> dill . dill . log . info ( '<STR_LIT>' ) <EOL> old_save_module_dict = dill . dill . save_module_dict <EOL> known_module_dicts = { } <EOL> @ dill . dill . register ( dict ) <EOL> def new_save_module_dict ( pickler , obj ) : <EOL> obj_id = id ( obj ) <EOL> if not known_module_dicts or '<STR_LIT>' in obj or '<STR_LIT>' in obj : <EOL> if obj_id not in known_module_dicts : <EOL> for m in sys . modules . values ( ) : <EOL> if m and m . __name__ != '<STR_LIT:__main__>' : <EOL> known_module_dicts [ id ( m . __dict__ ) ] = m <EOL> if obj_id in known_module_dicts and dill . dill . is_dill ( pickler ) and False : <EOL> return pickler . save_reduce ( <EOL> getattr , ( known_module_dicts [ obj_id ] , '<STR_LIT>' ) , obj = obj ) <EOL> else : <EOL> return old_save_module_dict ( pickler , obj ) <EOL> dill . dill . save_module_dict = new_save_module_dict <EOL> def _nest_dill_logging ( ) : <EOL> """<STR_LIT>""" <EOL> old_log_info = dill . dill . log . info <EOL> def new_log_info ( msg , * args , ** kwargs ) : <EOL> old_log_info ( <EOL> ( '<STR_LIT>' * <NUM_LIT:10> ) [ : len ( traceback . extract_stack ( ) ) ] + msg , <EOL> * args , ** kwargs ) <EOL> dill . dill . log . info = new_log_info <EOL> logging . getLogger ( '<STR_LIT>' ) . setLevel ( logging . WARN ) <EOL> def dumps ( o ) : <EOL> try : <EOL> return base64 . b64encode ( dill . dumps ( o ) ) <EOL> except Exception : <EOL> dill . dill . _trace ( True ) <EOL> return base64 . b64encode ( dill . dumps ( o ) ) <EOL> finally : <EOL> dill . dill . _trace ( False ) <EOL> def loads ( s ) : <EOL> try : <EOL> return dill . loads ( base64 . b64decode ( s ) ) <EOL> except Exception : <EOL> dill . dill . _trace ( True ) <EOL> return dill . loads ( base64 . b64decode ( s ) ) <EOL> finally : <EOL> dill . dill . _trace ( False ) <EOL> def dump_session ( file_path ) : <EOL> return dill . dump_session ( file_path ) <EOL> def load_session ( file_path ) : <EOL> return dill . load_session ( file_path ) </s>
