Skip to content

Commit

Permalink
Try to fix encoding problems in Python 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Mortal committed May 2, 2015
1 parent 6048cfa commit bcacba0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions emailtunnel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ def handle_error(self):


class SMTPReceiver(smtpd.SMTPServer):
channel_class = ResilientSMTPChannel
if six.PY3:
channel_class = ResilientSMTPChannel

def __init__(self, host, port):
self.host = host
Expand Down Expand Up @@ -371,7 +372,12 @@ def process_message(self, peer, mailfrom, rcpttos, str_data):
bytestring, which we unpack here.
"""

data = str_data.encode('latin1')
if six.PY3:
data = str_data.encode('latin1')
else:
data = str_data
logging.debug("Type of str_data is %s" % (type(str_data),))

if six.PY2:
if data.startswith('From nobody'):
# Remove first line which contains useless envelope info
Expand Down

0 comments on commit bcacba0

Please sign in to comment.