comparison mercurial/mail.py @ 43326:ef81de93143e stable

py3: use a BytesParser in notify extension This is the first step to make the "long line" case in test-notify.t pass by fixing a UnicodeDecodeError on Python 3. We alias a parsebytes() in mail module, similarly as we already have a parse() function for Python 2 and Python 3 compatibility.
author Denis Laxalde <denis.laxalde@logilab.fr>
date Thu, 24 Oct 2019 15:28:00 +0200
parents 7d4f2e4899c5
children 910827a2cb20
comparison
equal deleted inserted replaced
43325:7d4f2e4899c5 43326:ef81de93143e
438 try: 438 try:
439 return ep.parse(fp) 439 return ep.parse(fp)
440 finally: 440 finally:
441 fp.detach() 441 fp.detach()
442 442
443 def parsebytes(data):
444 ep = email.parser.BytesParser()
445 return ep.parsebytes(data)
443 446
444 else: 447 else:
445 448
446 Generator = email.generator.Generator 449 Generator = email.generator.Generator
447 450
448 def parse(fp): 451 def parse(fp):
449 ep = email.parser.Parser() 452 ep = email.parser.Parser()
450 return ep.parse(fp) 453 return ep.parse(fp)
454
455 def parsebytes(data):
456 ep = email.parser.Parser()
457 return ep.parsestr(data)
451 458
452 459
453 def headdecode(s): 460 def headdecode(s):
454 '''Decodes RFC-2047 header''' 461 '''Decodes RFC-2047 header'''
455 uparts = [] 462 uparts = []