[PATCH 06/15] Add workaround for string.split for Python3

Łukasz Żarnowiecki dolohow at outlook.com
Tue May 10 00:18:28 BST 2016


Signed-off-by: Łukasz Żarnowiecki <dolohow at outlook.com>
---
 offlineimap/imaputil.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/offlineimap/imaputil.py b/offlineimap/imaputil.py
index 1c0b495..e2bd280 100644
--- a/offlineimap/imaputil.py
+++ b/offlineimap/imaputil.py
@@ -161,7 +161,13 @@ def imapsplit(imapstring):
             retval.append(quoted)
             workstr = rest
         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)
             # The unquoted word is splits[0]; the remainder is splits[1]
             if splitslen == 2:
-- 
2.8.2





More information about the OfflineIMAP-project mailing list