Skip to content

Commit f557708

Browse files
committed
Fixed another py2/py3 issue with the nomcom mail processing script.
- Legacy-Id: 18602
1 parent 47354cb commit f557708

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ietf/nomcom/utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import re
99
import tempfile
1010

11-
from email import message_from_string
11+
from email import message_from_string, message_from_bytes
1212
from email.header import decode_header
1313
from email.iterators import typed_subpart_iterator
1414
from email.utils import parseaddr
@@ -20,7 +20,6 @@
2020
from django.urls import reverse
2121
from django.template.loader import render_to_string
2222
from django.shortcuts import get_object_or_404
23-
from django.utils.encoding import force_str
2423

2524
from ietf.dbtemplate.models import DBTemplate
2625
from ietf.person.models import Email, Person
@@ -450,7 +449,12 @@ def get_body(message):
450449

451450

452451
def parse_email(text):
453-
msg = message_from_string(force_str(text))
452+
if isinstance(text, bytes):
453+
msg = message_from_bytes(text)
454+
elif isinstance(text, str):
455+
msg = message_from_string(text)
456+
else:
457+
raise ValueError("Expected email message text to be str or bytes")
454458

455459
body = get_body(msg)
456460
subject = getheader(msg['Subject'])

0 commit comments

Comments
 (0)