def __getstate__(self):
        """Prepare object data for serialization.

    This converts any instance methods to the bound object (if any) and the
    method name.

    """
        f = self.f
        if getattr(f, 'func_name', None) == '<lambda>':
            raise PicklingError("Lambda functions can not be serialized")
        isbound = isinstance(f, types.MethodType)
        if isbound:
            if f.__self__ is None:
                raise PicklingError("Unbound methods can not be serialized")
            f = (f.__self__, f.__func__.__name__)
        return (isbound, f, self.args, self.kw)
Beispiel #2
0
    def __getstate__(self):
        if not self.feature_extractors_fqname:
            raise PicklingError("Can't pickle a Featurizer without a fully-"
                                "qualified name from which to restore"
                                " extractors")

        state = self.__dict__.copy()
        for attr_name in [
                'featurized', 'all_feature_extractors',
                '_selected_base_extractors', '_unselected_base_extractors',
                '_conjoined_extractors'
        ]:
            del state[attr_name]
        state['selected_features'] = self.get_selected_features(
            self.feature_name_dictionary)
        return state
Beispiel #3
0
 def __getstate__(self):
     # disallow persistent storage
     raise PicklingError("Temporary objects can't be pickled")
Beispiel #4
0
 def __getstate__(self):
     try:
         return dict(self.nodes.items())
     except Exception as e:
         raise PicklingError('Unable to pickle: {}'.format(e))
Beispiel #5
0
 def persistent_id(obj):
     if isinstance(obj, Deferred):
         raise PicklingError('%s cannot be serialized' % obj)
     return None
Beispiel #6
0
 def __getstate__(self):  # pragma: no cover
     raise PicklingError("Node cannot be serialized")
 def raise_error():
     raise PicklingError("SomeMessage")