From c27e52265b7ff4aa57dc357c289cce8c9dd0fec3 Mon Sep 17 00:00:00 2001 From: R David Murray Date: Fri, 25 May 2012 15:01:48 -0400 Subject: #14731: refactor email policy framework. This patch primarily does two things: (1) it adds some internal-interface methods to Policy that allow for Policy to control the parsing and folding of headers in such a way that we can construct a backward compatibility policy that is 100% compatible with the 3.2 API, while allowing a new policy to implement the email6 API. (2) it adds that backward compatibility policy and refactors the test suite so that the only differences between the 3.2 test_email.py file and the 3.3 test_email.py file is some small changes in test framework and the addition of tests for bugs fixed that apply to the 3.2 API. There are some additional teaks, such as moving just the code needed for the compatibility policy into _policybase, so that the library code can import only _policybase. That way the new code that will be added for email6 will only get imported when a non-compatibility policy is imported. --- Lib/email/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Lib/email/parser.py') diff --git a/Lib/email/parser.py b/Lib/email/parser.py index 0f921609dd..1aab012115 100644 --- a/Lib/email/parser.py +++ b/Lib/email/parser.py @@ -11,12 +11,12 @@ from io import StringIO, TextIOWrapper from email.feedparser import FeedParser from email.message import Message -from email import policy +from email._policybase import compat32 class Parser: - def __init__(self, _class=Message, *, policy=policy.default): + def __init__(self, _class=Message, *, policy=compat32): """Parser of RFC 2822 and MIME email messages. Creates an in-memory object tree representing the email message, which -- cgit v1.2.1