Kaydet (Commit) d2ff243b authored tarafından R David Murray's avatar R David Murray

Merge: #21991: make headerregistry params property MappingProxyType.

...@@ -7,6 +7,7 @@ Eventually HeaderRegistry will be a public API, but it isn't yet, ...@@ -7,6 +7,7 @@ Eventually HeaderRegistry will be a public API, but it isn't yet,
and will probably change some before that happens. and will probably change some before that happens.
""" """
from types import MappingProxyType
from email import utils from email import utils
from email import errors from email import errors
...@@ -456,7 +457,7 @@ class ParameterizedMIMEHeader: ...@@ -456,7 +457,7 @@ class ParameterizedMIMEHeader:
@property @property
def params(self): def params(self):
return self._params.copy() return MappingProxyType(self._params)
class ContentTypeHeader(ParameterizedMIMEHeader): class ContentTypeHeader(ParameterizedMIMEHeader):
......
import datetime import datetime
import textwrap import textwrap
import unittest import unittest
import types
from email import errors from email import errors
from email import policy from email import policy
from email.message import Message from email.message import Message
...@@ -235,6 +236,8 @@ class TestContentTypeHeader(TestHeaderBase): ...@@ -235,6 +236,8 @@ class TestContentTypeHeader(TestHeaderBase):
self.assertEqual(h.maintype, maintype) self.assertEqual(h.maintype, maintype)
self.assertEqual(h.subtype, subtype) self.assertEqual(h.subtype, subtype)
self.assertEqual(h.params, parmdict) self.assertEqual(h.params, parmdict)
with self.assertRaises(TypeError):
h.params['abc'] = 'xyz' # params is read-only.
self.assertDefectsEqual(h.defects, defects) self.assertDefectsEqual(h.defects, defects)
self.assertEqual(h, decoded) self.assertEqual(h, decoded)
self.assertEqual(h.fold(policy=policy.default), folded) self.assertEqual(h.fold(policy=policy.default), folded)
......
...@@ -181,6 +181,10 @@ Core and Builtins ...@@ -181,6 +181,10 @@ Core and Builtins
Library Library
------- -------
- Issue #21991: Make email.headerregistry's header 'params' attributes
be read-only (MappingProxyType). Previously the dictionary was modifiable
but a new one was created on each access of the attribute.
- Issue #22638: SSLv3 is now disabled throughout the standard library. - Issue #22638: SSLv3 is now disabled throughout the standard library.
It can still be enabled by instantiating a SSLContext manually. It can still be enabled by instantiating a SSLContext manually.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment