summaryrefslogtreecommitdiff
path: root/Lib/email/utils.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2012-05-25 15:01:48 -0400
committerR David Murray <rdmurray@bitdance.com>2012-05-25 15:01:48 -0400
commit25a003a10f523a12abae1f81ab0119f1ae170777 (patch)
tree4b97de417284a294329c05699e53147cbe6f2ef3 /Lib/email/utils.py
parent3652779172003429e5ec38bb6b4cc7dbc28f2a14 (diff)
downloadcpython-25a003a10f523a12abae1f81ab0119f1ae170777.tar.gz
#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.
Diffstat (limited to 'Lib/email/utils.py')
-rw-r--r--Lib/email/utils.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/email/utils.py b/Lib/email/utils.py
index 138f05dfdb..b82d5c578b 100644
--- a/Lib/email/utils.py
+++ b/Lib/email/utils.py
@@ -57,6 +57,10 @@ TICK = "'"
specialsre = re.compile(r'[][\\()<>@,:;".]')
escapesre = re.compile(r'[\\"]')
+# How to figure out if we are processing strings that come from a byte
+# source with undecodable characters.
+_has_surrogates = re.compile(
+ '([^\ud800-\udbff]|\A)[\udc00-\udfff]([^\udc00-\udfff]|\Z)').search
# Helpers