R. David Murray added the comment: There is no reason to move this to the email package. email can already parse headers just fine. It might be useful to have a parse_header utility method, though, since currently the easiest way to parse a single header using the email package is:
>>> from email.policy import HTTP >>> from email.parser import Parser >>> m = Parser(policy=HTTP).parsestr('Content-Type: text/plain; filename="foo"\n\n') >>> m['Content-Type'].content_type 'text/plain' >>> m['Content-type'].params mappingproxy({'filename': 'foo'}) Which isn't as straightforward as the parse_header API when you are only interested in a single header. It might also be useful to have the email MIME headers grow a 'value' attribute to return whatever the value is (in this case, text/plain), so it can be accessed regardless of the header type. I would make parse_header be a utility method of the policy, I think. Then the email API would be: from email.policy import HTTP h = HTTP.parse_header('Content-Type: ...') value, params = h.value, h.params It would then be trivial to implement the backward compatibility shim for the CGI parse_header method using the above. ---------- stage: patch review -> needs patch versions: +Python 3.5 -Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue3609> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com