/usr/lib/python3/dist-packages/sentinels/__init__.py is in python3-sentinels 1.0.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | from .__version__ import __version__
try:
# python3 renamed copy_reg to copyreg
import copyreg
except ImportError:
import copy_reg as copyreg
class Sentinel(object):
_existing_instances = {}
def __init__(self, name):
super(Sentinel, self).__init__()
self._name = name
self._existing_instances[self._name] = self
def __repr__(self):
return "<{0}>".format(self._name)
def __getnewargs__(self):
return (self._name,)
def __new__(cls, name, obj_id=None): # obj_id is for compatibility with previous versions
existing_instance = cls._existing_instances.get(name)
if existing_instance is not None:
return existing_instance
return super(Sentinel, cls).__new__(cls)
def _sentinel_unpickler(name, obj_id=None): # obj_id is for compat. with prev. versions
if name in Sentinel._existing_instances:
return Sentinel._existing_instances[name]
return Sentinel(name)
def _sentinel_pickler(sentinel):
return _sentinel_unpickler, sentinel.__getnewargs__()
copyreg.pickle(Sentinel, _sentinel_pickler, _sentinel_unpickler)
NOTHING = Sentinel('NOTHING')
|