cpython: 5beb1ea76f36 (original) (raw)
Mercurial > cpython
changeset 93119:5beb1ea76f36
Merge: #21991: make headerregistry params property MappingProxyType. [#21991]
R David Murray rdmurray@bitdance.com | |
---|---|
date | Fri, 17 Oct 2014 19:32:08 -0400 |
parents | ccd93c7f2b3c(current diff)fea3ddcaf652(diff) |
children | b35a811d4420 |
files | Lib/email/headerregistry.py Misc/NEWS |
diffstat | 3 files changed, 9 insertions(+), 1 deletions(-)[+] [-] Lib/email/headerregistry.py 3 Lib/test/test_email/test_headerregistry.py 3 Misc/NEWS 4 |
line wrap: on
line diff
--- a/Lib/email/headerregistry.py +++ b/Lib/email/headerregistry.py @@ -7,6 +7,7 @@ Eventually HeaderRegistry will be a publ 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()[](#l1.15)
return MappingProxyType(self._params)[](#l1.16)
class ContentTypeHeader(ParameterizedMIMEHeader):
--- 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(TestHeaderBa self.assertEqual(h.maintype, maintype) self.assertEqual(h.subtype, subtype) self.assertEqual(h.params, parmdict)
with self.assertRaises(TypeError):[](#l2.15)
h.params['abc'] = 'xyz' # params is read-only.[](#l2.16) self.assertDefectsEqual(h.defects, defects)[](#l2.17) self.assertEqual(h, decoded)[](#l2.18) self.assertEqual(h.fold(policy=policy.default), folded)[](#l2.19)
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -181,6 +181,10 @@ Core and Builtins Library ------- +- Issue #21991: Make email.headerregistry's header 'params' attributes