--- a/Lib/email/utils.py Fri May 04 23:17:03 2012 +0200 +++ b/Lib/email/utils.py Sat May 05 12:41:33 2012 -0400 @@ -57,6 +57,10 @@ 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