Wrap bytes check in a wrapper to be a bit more efficient
This commit is contained in:
parent
0345390aa1
commit
f024bb9e4c
@ -299,6 +299,10 @@ class MaildirFolder(BaseFolder):
|
|||||||
fd = open(filepath, 'rb')
|
fd = open(filepath, 'rb')
|
||||||
retval = self.parser['8bit'].parse(fd)
|
retval = self.parser['8bit'].parse(fd)
|
||||||
try:
|
try:
|
||||||
|
if len(retval.defects) > 0:
|
||||||
|
ui.warn("Message has defects: {}".format(retval.defects))
|
||||||
|
# See if the defects are preventing us from obtaining bytes and
|
||||||
|
# handle known issues
|
||||||
_ = retval.as_bytes(policy=self.policy['8bit'])
|
_ = retval.as_bytes(policy=self.policy['8bit'])
|
||||||
except UnicodeEncodeError as err:
|
except UnicodeEncodeError as err:
|
||||||
if any(isinstance(defect, NoBoundaryInMultipartDefect) for defect in retval.defects):
|
if any(isinstance(defect, NoBoundaryInMultipartDefect) for defect in retval.defects):
|
||||||
|
Loading…
Reference in New Issue
Block a user