mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-22 07:53:19 +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))
|
logger.info("Received %d messages from POP3 server" % len(messagesInfo))
|
||||||
|
|
||||||
for msgRaw in messagesInfo:
|
for msgRaw in messagesInfo:
|
||||||
if six.PY3:
|
if six.PY3 and type(msgRaw) is bytes:
|
||||||
# in py3, msgRaw is a bytes object, decode to str
|
# in py3, msgRaw may be a bytes object, decode to str
|
||||||
try:
|
try:
|
||||||
msg = msgRaw.decode("utf-8")
|
msg = msgRaw.decode("utf-8")
|
||||||
except UnicodeError:
|
except UnicodeError:
|
||||||
# if couldn't decode easily, just leave it raw
|
# if couldn't decode easily, just leave it raw
|
||||||
msg = msgRaw
|
msg = msgRaw
|
||||||
else:
|
else:
|
||||||
# in py2, already a str
|
# already a str
|
||||||
msg = msgRaw
|
msg = msgRaw
|
||||||
msgNum = msg.split(" ")[0]
|
msgNum = msg.split(" ")[0]
|
||||||
logger.info("Processing message %s" % msgNum)
|
logger.info("Processing message %s" % msgNum)
|
||||||
|
Loading…
Reference in New Issue
Block a user