diff options
author | R David Murray <rdmurray@bitdance.com> | 2014-10-17 23:32:08 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2014-10-17 23:32:08 (GMT) |
commit | d2ff243b3829d17b0a6a9ac5eab0c522f517f466 (patch) | |
tree | 6653bfa4a6deff9651ed7da99742b14d2082e8a9 | |
parent | 77770bdaa80ad0b6e976f11135c7c865efe23ae8 (diff) | |
parent | 685b3495e1fd9853b1ca5960db3e3cb705920d4f (diff) | |
download | cpython-d2ff243b3829d17b0a6a9ac5eab0c522f517f466.zip cpython-d2ff243b3829d17b0a6a9ac5eab0c522f517f466.tar.gz cpython-d2ff243b3829d17b0a6a9ac5eab0c522f517f466.tar.bz2 |
Merge: #21991: make headerregistry params property MappingProxyType.
-rw-r--r-- | Lib/email/headerregistry.py | 3 | ||||
-rw-r--r-- | Lib/test/test_email/test_headerregistry.py | 3 | ||||
-rw-r--r-- | Misc/NEWS | 4 |
3 files changed, 9 insertions, 1 deletions
diff --git a/Lib/email/headerregistry.py b/Lib/email/headerregistry.py index 2bdae6c..468ca9e 100644 --- a/Lib/email/headerregistry.py +++ b/Lib/email/headerregistry.py @@ -7,6 +7,7 @@ Eventually HeaderRegistry will be a public API, but it isn't yet, and will probably change some before that happens. """ +from types import MappingProxyType from email import utils from email import errors @@ -456,7 +457,7 @@ class ParameterizedMIMEHeader: @property def params(self): - return self._params.copy() + return MappingProxyType(self._params) class ContentTypeHeader(ParameterizedMIMEHeader): diff --git a/Lib/test/test_email/test_headerregistry.py b/Lib/test/test_email/test_headerregistry.py index 7d64a38..55ecdea 100644 --- a/Lib/test/test_email/test_headerregistry.py +++ b/Lib/test/test_email/test_headerregistry.py @@ -1,6 +1,7 @@ import datetime import textwrap import unittest +import types from email import errors from email import policy from email.message import Message @@ -235,6 +236,8 @@ class TestContentTypeHeader(TestHeaderBase): self.assertEqual(h.maintype, maintype) self.assertEqual(h.subtype, subtype) self.assertEqual(h.params, parmdict) + with self.assertRaises(TypeError): + h.params['abc'] = 'xyz' # params is read-only. self.assertDefectsEqual(h.defects, defects) self.assertEqual(h, decoded) self.assertEqual(h.fold(policy=policy.default), folded) @@ -181,6 +181,10 @@ Core and Builtins 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. It can still be enabled by instantiating a SSLContext manually. |