diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2014-03-27 15:31:43 (GMT) |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2014-03-27 15:31:43 (GMT) |
commit | a5d63dd7b880dd38282ad52f52e3579f965b20e0 (patch) | |
tree | b274d50a58057775bea3521a5622ab8f571b565b /Lib/inspect.py | |
parent | 21e83a5564862d2a6d336c2896070ba5539bddcd (diff) | |
download | cpython-a5d63dd7b880dd38282ad52f52e3579f965b20e0.zip cpython-a5d63dd7b880dd38282ad52f52e3579f965b20e0.tar.gz cpython-a5d63dd7b880dd38282ad52f52e3579f965b20e0.tar.bz2 |
inspect.signature: Make Signature and Parameter picklable. Closes #20726
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index 6054c39..bce0516 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -2106,6 +2106,18 @@ class Parameter: self._partial_kwarg = _partial_kwarg + def __reduce__(self): + return (type(self), + (self._name, self._kind), + {'_partial_kwarg': self._partial_kwarg, + '_default': self._default, + '_annotation': self._annotation}) + + def __setstate__(self, state): + self._partial_kwarg = state['_partial_kwarg'] + self._default = state['_default'] + self._annotation = state['_annotation'] + @property def name(self): return self._name @@ -2658,6 +2670,14 @@ class Signature: ''' return args[0]._bind(args[1:], kwargs, partial=True) + def __reduce__(self): + return (type(self), + (tuple(self._parameters.values()),), + {'_return_annotation': self._return_annotation}) + + def __setstate__(self, state): + self._return_annotation = state['_return_annotation'] + def __str__(self): result = [] render_pos_only_separator = False |