KW_ONLY = _KW_ONLY_TYPE()
# Since most per-field metadata will be unused, create an empty
-# read-only proxy that can be shared among all fields.
-_EMPTY_METADATA = types.MappingProxyType({})
+# read-only dictionary that can be shared among all fields.
+_EMPTY_METADATA = frozendict()
# Markers for the various kinds of fields and pseudo-fields.
class _FIELD_BASE:
This module provides an implementation of the HeaderRegistry API.
The implementation is designed to flexibly follow RFC5322 rules.
"""
-from types import MappingProxyType
-
from email import utils
from email import errors
from email import _header_value_parser as parser
@property
def params(self):
- return MappingProxyType(self._params)
+ return frozendict(self._params)
class ContentTypeHeader(ParameterizedMIMEHeader):
import unittest
import unittest.mock
from test.support import import_helper
-from types import MappingProxyType
def _parse_fullname(fullname, *, strict=False):
)
-_HASHINFO_DATABASE = MappingProxyType({
+_HASHINFO_DATABASE = frozendict({
_HashId.md5: _HashInfo(
_HashId.md5,
"_md5.MD5Type",
# keyed hash function. However, as it's exposed by HACL*, we test it.
_HMACINFO_DATABASE[_HashId.blake2s] = _HashInfoItem('_hmac.compute_blake2s_32')
_HMACINFO_DATABASE[_HashId.blake2b] = _HashInfoItem('_hmac.compute_blake2b_32')
-_HMACINFO_DATABASE = MappingProxyType(_HMACINFO_DATABASE)
+_HMACINFO_DATABASE = frozendict(_HMACINFO_DATABASE)
assert _HMACINFO_DATABASE.keys() == CANONICAL_DIGEST_NAMES
expected_output = "Field(name='id',type=None," \
f"default=1,default_factory={MISSING!r}," \
"init=True,repr=False,hash=None," \
- "compare=True,metadata=mappingproxy({})," \
+ "compare=True,metadata=frozendict()," \
f"kw_only={MISSING!r}," \
"doc='Docstring'," \
"_field_type=None)"
import hmac
import hashlib
import random
-import types
import unittest
import warnings
from _operator import _compare_digest as operator_compare_digest
def check_hmac_new(
self, key, msg, hexdigest, hashname, digest_size, block_size,
- hmac_new_func, hmac_new_kwds=types.MappingProxyType({}),
+ hmac_new_func, hmac_new_kwds=frozendict(),
):
"""Check that HMAC(key, msg) == digest.
def check_hmac_hexdigest(
self, key, msg, hexdigest, digest_size,
- hmac_digest_func, hmac_digest_kwds=types.MappingProxyType({}),
+ hmac_digest_func, hmac_digest_kwds=frozendict(),
):
"""Check and return a HMAC digest computed by hmac_digest_func().