/usr/lib/python3.9/site-packages/dns
NameSizeModeActions
dnssecalgs/-0755rm
quic/-0755rm
rdtypes/-0755rm
__pycache__/-0755rm
asyncbackend.py27960644editdlrm
asyncquery.py268500644editdlrm
asyncresolver.py178520644editdlrm
dnssec.py406930644editdlrm
dnssectypes.py17990644editdlrm
e164.py39780644editdlrm
edns.py152630644editdlrm
entropy.py42420644editdlrm
enum.py36910644editdlrm
exception.py59570644editdlrm
flags.py27500644editdlrm
grange.py21480644editdlrm
immutable.py20170644editdlrm
inet.py57720644editdlrm
ipv4.py25520644editdlrm
ipv6.py66000644editdlrm
message.py659930644editdlrm
name.py426720644editdlrm
namedict.py40000644editdlrm
nameserver.py99090644editdlrm
node.py126630644editdlrm
opcode.py27300644editdlrm
query.py548320644editdlrm
rcode.py41560644editdlrm
rdata.py294560644editdlrm
rdataclass.py29840644editdlrm
rdataset.py167560644editdlrm
rdatatype.py73390644editdlrm
renderer.py112540644editdlrm
resolver.py735520644editdlrm
reversename.py38280644editdlrm
rrset.py91700644editdlrm
serial.py36060644editdlrm
set.py90880644editdlrm
tokenizer.py235830644editdlrm
transaction.py226360644editdlrm
tsig.py114130644editdlrm
tsigkeyring.py26330644editdlrm
ttl.py29790644editdlrm
update.py122430644editdlrm
version.py19260644editdlrm
versioned.py117650644editdlrm
win32util.py91070644editdlrm
wire.py28300644editdlrm
xfr.py132730644editdlrm
zone.py520860644editdlrm
zonefile.py279290644editdlrm
zonetypes.py6900644editdlrm
_asyncbackend.py23600644editdlrm
_asyncio_backend.py89710644editdlrm
_ddr.py52470644editdlrm
_features.py23840644editdlrm
_immutable_ctx.py24590644editdlrm
__init__.py16630644editdlrm
Edit: /usr/lib/python3.9/site-packages/dns/immutable.py (2017B)
# Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license import collections.abc from typing import Any, Callable from dns._immutable_ctx import immutable @immutable class Dict(collections.abc.Mapping): # lgtm[py/missing-equals] def __init__( self, dictionary: Any, no_copy: bool = False, map_factory: Callable[[], collections.abc.MutableMapping] = dict, ): """Make an immutable dictionary from the specified dictionary. If *no_copy* is `True`, then *dictionary* will be wrapped instead of copied. Only set this if you are sure there will be no external references to the dictionary. """ if no_copy and isinstance(dictionary, collections.abc.MutableMapping): self._odict = dictionary else: self._odict = map_factory() self._odict.update(dictionary) self._hash = None def __getitem__(self, key): return self._odict.__getitem__(key) def __hash__(self): # pylint: disable=invalid-hash-returned if self._hash is None: h = 0 for key in sorted(self._odict.keys()): h ^= hash(key) object.__setattr__(self, "_hash", h) # this does return an int, but pylint doesn't figure that out return self._hash def __len__(self): return len(self._odict) def __iter__(self): return iter(self._odict) def constify(o: Any) -> Any: """ Convert mutable types to immutable types. """ if isinstance(o, bytearray): return bytes(o) if isinstance(o, tuple): try: hash(o) return o except Exception: return tuple(constify(elt) for elt in o) if isinstance(o, list): return tuple(constify(elt) for elt in o) if isinstance(o, dict): cdict = dict() for k, v in o.items(): cdict[k] = constify(v) return Dict(cdict, True) return o