def unpickleMethod(im_name, im_self, im_class):
 if (im_self is None):
  return getattr(im_class, im_name)
 try:
  methodFunction = _methodFunction(im_class, im_name)
 except AttributeError:
  log.msg('Method', im_name, 'not on class', im_class)
  assert (im_self is not None), 'No recourse: no instance to guess from.'
  if (im_self.__class__ is im_class):
   raise
  return unpickleMethod(im_name, im_self, im_self.__class__)
 else:
  if _PY3:
   maybeClass = ()
  else:
   maybeClass = tuple([im_class])
  bound = types.MethodType(methodFunction, im_self, *maybeClass)
  return bound

def unpickleMethod ( im_name , im_self , im_class ) : if ( im_self is None ) : return getattr ( im_class , im_name ) try : methodFunction = _methodFunction ( im_class , im_name ) except AttributeError : log . msg ( 'Method' , im_name , 'not on class' , im_class ) assert ( im_self is not None ) , 'No recourse: no instance to guess from.' if ( im_self . __class__ is im_class ) : raise return unpickleMethod ( im_name , im_self , im_self . __class__ ) else : if _PY3 : maybeClass = ( ) else : maybeClass = tuple ( [ im_class ] ) bound = types . MethodType ( methodFunction , im_self , * maybeClass ) return bound
support function for copy_reg to unpickle method refs .