mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-25 09:23:39 +01:00
Fix bytes/str confusion in Py3 after address naked except
This commit is contained in:
parent
c085dba901
commit
a2c10edb35
@ -161,15 +161,15 @@ def process_queue(q, logger):
|
||||
logger.info("Received %d messages from POP3 server" % len(messagesInfo))
|
||||
|
||||
for msgRaw in messagesInfo:
|
||||
if six.PY3:
|
||||
# in py3, msgRaw is a bytes object, decode to str
|
||||
if six.PY3 and type(msgRaw) is bytes:
|
||||
# in py3, msgRaw may be a bytes object, decode to str
|
||||
try:
|
||||
msg = msgRaw.decode("utf-8")
|
||||
except UnicodeError:
|
||||
# if couldn't decode easily, just leave it raw
|
||||
msg = msgRaw
|
||||
else:
|
||||
# in py2, already a str
|
||||
# already a str
|
||||
msg = msgRaw
|
||||
msgNum = msg.split(" ")[0]
|
||||
logger.info("Processing message %s" % msgNum)
|
||||
|
Loading…
Reference in New Issue
Block a user