X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=bindings%2Fpython%2Fnotmuch%2Fdatabase.py;h=2eae69ed72ae6aebde5671a55df97500899b4161;hp=5b1b00bd6f2df42124253ccd688f14340318375e;hb=83b256b12be25b29f915587342b5ccb139864268;hpb=71e0082eff05f52709500109f1a194fdb03571e5 diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py index 5b1b00bd..2eae69ed 100644 --- a/bindings/python/notmuch/database.py +++ b/bindings/python/notmuch/database.py @@ -79,7 +79,6 @@ class Database(object): _open = nmlib.notmuch_database_open _open.argtypes = [c_char_p, c_uint] _open.restype = NotmuchDatabaseP - #_open.restype = c_void_p """notmuch_database_upgrade""" _upgrade = nmlib.notmuch_database_upgrade @@ -431,7 +430,7 @@ class Database(object): removed. """ self._assert_db_is_initialized() - return self._remove_message(self._db, filename) + return self._remove_message(self._db, _str(filename)) def find_message(self, msgid): """Returns a :class:`Message` as identified by its message ID @@ -544,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')) @@ -920,7 +925,7 @@ class Filenames(object): _move_to_next.argtypes = [NotmuchFilenamesP] _move_to_next.restype = None - def next(self): + def __next__(self): if self._files_p is None: raise NotmuchError(STATUS.NOT_INITIALIZED) @@ -928,9 +933,10 @@ class Filenames(object): self._files_p = None raise StopIteration - file = Filenames._get(self._files_p) + file_ = Filenames._get(self._files_p) self._move_to_next(self._files_p) - return file + return file_.decode('utf-8', errors='ignore') + next = __next__ # python2.x iterator protocol compatibility def __len__(self): """len(:class:`Filenames`) returns the number of contained files