py3k: The ConfigParser module has been renamed to configparser
authorJustus Winter <4winter@informatik.uni-hamburg.de>
Wed, 14 Dec 2011 10:58:20 +0000 (11:58 +0100)
committerSebastian Spaeth <Sebastian@SSpaeth.de>
Mon, 2 Jan 2012 15:08:32 +0000 (16:08 +0100)
bindings/python/notmuch.py
bindings/python/notmuch/database.py

index 8d1185953b5ccd50c9032b1220624873857701af..3ff53ec8c60ed6459a9eb36b03bf81e246eca838 100755 (executable)
@@ -17,7 +17,12 @@ import stat
 import email
 
 from notmuch import Database, Query, NotmuchError, STATUS
-from ConfigParser import SafeConfigParser
+try:
+    # python3.x
+    from configparser import SafeConfigParser
+except ImportError:
+    # python2.x
+    from ConfigParser import SafeConfigParser
 from cStringIO import StringIO
 
 PREFIX = re.compile('(\w+):(.*$)')
index 7923f768b1f78caec831c3018b5280367feb9712..93183687a4259c8aebe391ccb342c4b577493366 100644 (file)
@@ -543,7 +543,13 @@ class Database(object):
         """ Reads a user's notmuch config and returns his db location
 
         Throws a NotmuchError if it cannot find it"""
-        from ConfigParser import SafeConfigParser
+        try:
+            # python3.x
+            from configparser import SafeConfigParser
+        except ImportError:
+            # python2.x
+            from ConfigParser import SafeConfigParser
+
         config = SafeConfigParser()
         conf_f = os.getenv('NOTMUCH_CONFIG',
                            os.path.expanduser('~/.notmuch-config'))