Mercurial > hg
view mercurial/thirdparty/cbor/cbor2/types.py @ 50757:19108906abaf stable
extensions: imp module is removed in Python 3.12 - use importlib to load files
imp has been deprecated for a long time, and has finally been removed in Python
3.12 .
imp was only used for loading extensions that has been specified with direct
.py path or path to a package directory. The same use cases can be achieved
quite simple with importlib, , possiby with small changes in corner cases with
undefined behaviour, such as extensions without .py source.
There might also be corner cases and undefined behaviour around use of
sys.modules and reloading.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Wed, 28 Jun 2023 14:23:13 +0200 |
parents | 4bd73a955ab0 |
children |
line wrap: on
line source
class CBORTag(object): """ Represents a CBOR semantic tag. :param int tag: tag number :param value: encapsulated value (any object) """ __slots__ = 'tag', 'value' def __init__(self, tag, value): self.tag = tag self.value = value def __eq__(self, other): if isinstance(other, CBORTag): return self.tag == other.tag and self.value == other.value return NotImplemented def __repr__(self): return 'CBORTag({self.tag}, {self.value!r})'.format(self=self) class CBORSimpleValue(object): """ Represents a CBOR "simple value". :param int value: the value (0-255) """ __slots__ = 'value' def __init__(self, value): if value < 0 or value > 255: raise TypeError('simple value too big') self.value = value def __eq__(self, other): if isinstance(other, CBORSimpleValue): return self.value == other.value elif isinstance(other, int): return self.value == other return NotImplemented def __repr__(self): return 'CBORSimpleValue({self.value})'.format(self=self) class UndefinedType(object): __slots__ = () #: Represents the "undefined" value. undefined = UndefinedType() break_marker = object()