def findCtypesInPyObj(memory_handler, obj): """ check function to help in unpickling errors correction """ if hasattr(obj, 'findCtypes'): if obj.findCtypes(): log.warning('Found a self._ctypes in array/tuple') return True elif isinstance(obj, tuple) or isinstance(obj, list): for el in obj: if findCtypesInPyObj(memory_handler, el): log.warning('Found a self._ctypes in array/tuple') return True elif types.is_ctypes_instance(obj): return True return False
def _attrFindCtypes(self, attr, attrname, typ, cache): ret = False cache.add(id(attr)) if hasattr(attr, '_ctype_'): # a pyobj return attr.findCtypes(cache) elif isinstance(attr, tuple) or isinstance(attr, list): for el in attr: if self._attrFindCtypes(el, 'element', None, cache): log.warning('Found a self._ctypes in array/tuple') return True elif types.is_ctypes_instance(attr): log.warning('Found a self._ctypes in self %s' % (attr)) return True else: # int, long, str ... ret = False return ret