mirror of
https://github.com/python/cpython.git
synced 2026-02-21 22:50:55 +00:00
gh-141510: Replace MappingProxyType with frozendict (#144904)
This commit is contained in:
parent
16ccdbc50a
commit
0bbdb4e897
5 changed files with 8 additions and 12 deletions
|
|
@ -191,8 +191,8 @@ class _KW_ONLY_TYPE:
|
|||
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:
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
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
|
||||
|
|
@ -462,7 +460,7 @@ def init(self, *args, **kw):
|
|||
|
||||
@property
|
||||
def params(self):
|
||||
return MappingProxyType(self._params)
|
||||
return frozendict(self._params)
|
||||
|
||||
|
||||
class ContentTypeHeader(ParameterizedMIMEHeader):
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
import unittest
|
||||
import unittest.mock
|
||||
from test.support import import_helper
|
||||
from types import MappingProxyType
|
||||
|
||||
|
||||
def _parse_fullname(fullname, *, strict=False):
|
||||
|
|
@ -351,7 +350,7 @@ def __init__(
|
|||
)
|
||||
|
||||
|
||||
_HASHINFO_DATABASE = MappingProxyType({
|
||||
_HASHINFO_DATABASE = frozendict({
|
||||
_HashId.md5: _HashInfo(
|
||||
_HashId.md5,
|
||||
"_md5.MD5Type",
|
||||
|
|
@ -500,7 +499,7 @@ def _iter_hash_func_info(excluded):
|
|||
# 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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ def test_field_repr(self):
|
|||
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)"
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
import hmac
|
||||
import hashlib
|
||||
import random
|
||||
import types
|
||||
import unittest
|
||||
import warnings
|
||||
from _operator import _compare_digest as operator_compare_digest
|
||||
|
|
@ -303,7 +302,7 @@ def assert_hmac_new_by_name(
|
|||
|
||||
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.
|
||||
|
||||
|
|
@ -349,7 +348,7 @@ def assert_hmac_hexdigest_by_name(
|
|||
|
||||
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().
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue