mirror of
https://github.com/python/cpython.git
synced 2025-08-28 12:45:07 +00:00
Issue #20804: The unittest.mock.sentinel attributes now preserve their
identity when they are copied or pickled.
This commit is contained in:
parent
d4f5001bac
commit
d9c956fb23
5 changed files with 33 additions and 0 deletions
|
@ -238,6 +238,9 @@ class _SentinelObject(object):
|
|||
def __repr__(self):
|
||||
return 'sentinel.%s' % self.name
|
||||
|
||||
def __reduce__(self):
|
||||
return 'sentinel.%s' % self.name
|
||||
|
||||
|
||||
class _Sentinel(object):
|
||||
"""Access attributes to return a named object, usable as a sentinel."""
|
||||
|
@ -250,6 +253,9 @@ class _Sentinel(object):
|
|||
raise AttributeError
|
||||
return self._sentinels.setdefault(name, _SentinelObject(name))
|
||||
|
||||
def __reduce__(self):
|
||||
return 'sentinel'
|
||||
|
||||
|
||||
sentinel = _Sentinel()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue