##// END OF EJS Templates
mail: delete conditional code for Python 2...
Gregory Szorc -
r49738:f0c445a8 default
parent child Browse files
Show More
@@ -467,43 +467,28 b' def mimeencode(ui, s, charsets=None, dis'
467 return mimetextqp(s, 'plain', cs)
467 return mimetextqp(s, 'plain', cs)
468
468
469
469
470 if pycompat.ispy3:
470 Generator = email.generator.BytesGenerator
471
472 Generator = email.generator.BytesGenerator
473
474 def parse(fp):
475 # type: (Any) -> email.message.Message
476 ep = email.parser.Parser()
477 # disable the "universal newlines" mode, which isn't binary safe.
478 # I have no idea if ascii/surrogateescape is correct, but that's
479 # what the standard Python email parser does.
480 fp = io.TextIOWrapper(
481 fp, encoding='ascii', errors='surrogateescape', newline=chr(10)
482 )
483 try:
484 return ep.parse(fp)
485 finally:
486 fp.detach()
487
488 def parsebytes(data):
489 # type: (bytes) -> email.message.Message
490 ep = email.parser.BytesParser()
491 return ep.parsebytes(data)
492
471
493
472
494 else:
473 def parse(fp):
495
474 # type: (Any) -> email.message.Message
496 Generator = email.generator.Generator
475 ep = email.parser.Parser()
476 # disable the "universal newlines" mode, which isn't binary safe.
477 # I have no idea if ascii/surrogateescape is correct, but that's
478 # what the standard Python email parser does.
479 fp = io.TextIOWrapper(
480 fp, encoding='ascii', errors='surrogateescape', newline=chr(10)
481 )
482 try:
483 return ep.parse(fp)
484 finally:
485 fp.detach()
497
486
498 def parse(fp):
499 # type: (Any) -> email.message.Message
500 ep = email.parser.Parser()
501 return ep.parse(fp)
502
487
503 def parsebytes(data):
488 def parsebytes(data):
504 # type: (str) -> email.message.Message
489 # type: (bytes) -> email.message.Message
505 ep = email.parser.Parser()
490 ep = email.parser.BytesParser()
506 return ep.parsestr(data)
491 return ep.parsebytes(data)
507
492
508
493
509 def headdecode(s):
494 def headdecode(s):
General Comments 0
You need to be logged in to leave comments. Login now