MCPcopy Index your code
hub / github.com/python/cpython / __setstate__

Method __setstate__

Lib/functools.py:404–432  ·  view source on GitHub ↗
(self, state)

Source from the content-addressed store, hash-verified

402 self.keywords or None, self.__dict__ or None)
403
404 def __setstate__(self, state):
405 if not isinstance(state, tuple):
406 raise TypeError("argument to __setstate__ must be a tuple")
407 if len(state) != 4:
408 raise TypeError(f"expected 4 items in state, got {len(state)}")
409 func, args, kwds, namespace = state
410 if (not callable(func) or not isinstance(args, tuple) or
411 (kwds is not None and not isinstance(kwds, dict)) or
412 (namespace is not None and not isinstance(namespace, dict))):
413 raise TypeError("invalid partial state")
414
415 if args and args[-1] is Placeholder:
416 raise TypeError("trailing Placeholders are not allowed")
417 phcount, merger = _partial_prepare_merger(args)
418
419 args = tuple(args) # just in case it's a subclass
420 if kwds is None:
421 kwds = {}
422 elif type(kwds) is not dict: # XXX does it need to be *exactly* dict?
423 kwds = dict(kwds)
424 if namespace is None:
425 namespace = {}
426
427 self.__dict__ = namespace
428 self.func = func
429 self.args = args
430 self.keywords = kwds
431 self._phcount = phcount
432 self._merger = merger
433
434 __class_getitem__ = classmethod(GenericAlias)
435

Callers

nothing calls this directly

Calls 1

_partial_prepare_mergerFunction · 0.85

Tested by

no test coverage detected