Add workaround for string.split for Python3

Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Łukasz Żarnowiecki 2016-05-08 15:51:59 +02:00 committed by Nicolas Sebrecht
parent 4fbb5640ac
commit 3848bc55f3

View File

@ -161,7 +161,13 @@ def imapsplit(imapstring):
retval.append(quoted) retval.append(quoted)
workstr = rest workstr = rest
else: else:
splits = string.split(workstr, maxsplit = 1) splits = None
# Python2
if hasattr(string, 'split'):
splits = string.split(workstr, maxsplit = 1)
# Python3
else:
splits = str.split(workstr, maxsplit = 1)
splitslen = len(splits) splitslen = len(splits)
# The unquoted word is splits[0]; the remainder is splits[1] # The unquoted word is splits[0]; the remainder is splits[1]
if splitslen == 2: if splitslen == 2: