diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py index 3913367..e3f863c 100644 --- a/offlineimap/folder/Base.py +++ b/offlineimap/folder/Base.py @@ -524,13 +524,16 @@ class BaseFolder: raise NotImplementedError - def savemessagelabels(self, uid, labels, ignorelabels=set(), mtime=0): + def savemessagelabels(self, uid, labels, ignorelabels=None, mtime=0): """Sets the specified message's labels to the given set. Note that this function does not check against dryrun settings, so you need to ensure that it is never called in a dryrun mode.""" + if ignorelabels is None: + ignorelabels = set() + raise NotImplementedError def addmessagelabels(self, uid, labels): diff --git a/offlineimap/folder/GmailMaildir.py b/offlineimap/folder/GmailMaildir.py index 4114dd4..ebefd1b 100644 --- a/offlineimap/folder/GmailMaildir.py +++ b/offlineimap/folder/GmailMaildir.py @@ -133,12 +133,15 @@ class GmailMaildirFolder(MaildirFolder): self.messagelist[uid]['labels'] = labels return ret - def savemessagelabels(self, uid, labels, ignorelabels=set()): + def savemessagelabels(self, uid, labels, ignorelabels=None): """Change a message's labels to `labels`. Note that this function does not check against dryrun settings, so you need to ensure that it is never called in a dryrun mode.""" + if ignorelabels is None: + ignorelabels = set() + filename = self.messagelist[uid]['filename'] filepath = os.path.join(self.getfullname(), filename) diff --git a/offlineimap/folder/LocalStatus.py b/offlineimap/folder/LocalStatus.py index d1e2eb8..4f8d42d 100644 --- a/offlineimap/folder/LocalStatus.py +++ b/offlineimap/folder/LocalStatus.py @@ -190,13 +190,16 @@ class LocalStatusFolder(BaseFolder): os.close(fd) # Interface from BaseFolder - def savemessage(self, uid, content, flags, rtime, mtime=0, labels=set()): + def savemessage(self, uid, content, flags, rtime, mtime=0, labels=None): """Writes a new message, with the specified uid. See folder/Base for detail. Note that savemessage() does not check against dryrun settings, so you need to ensure that savemessage is never called in a dryrun mode.""" + if labels is None: + labels = set() + if uid < 0: # We cannot assign a uid. return uid diff --git a/offlineimap/folder/LocalStatusSQLite.py b/offlineimap/folder/LocalStatusSQLite.py index 5292463..27a9a81 100644 --- a/offlineimap/folder/LocalStatusSQLite.py +++ b/offlineimap/folder/LocalStatusSQLite.py @@ -323,13 +323,16 @@ class LocalStatusSQLiteFolder(BaseFolder): # assert False,"getmessageflags() called on non-existing message" # Interface from BaseFolder - def savemessage(self, uid, content, flags, rtime, mtime=0, labels=set()): + def savemessage(self, uid, content, flags, rtime, mtime=0, labels=None): """Writes a new message, with the specified uid. See folder/Base for detail. Note that savemessage() does not check against dryrun settings, so you need to ensure that savemessage is never called in a dryrun mode.""" + if labels is None: + labels = set() + if uid < 0: # We cannot assign a uid. return uid diff --git a/offlineimap/folder/Maildir.py b/offlineimap/folder/Maildir.py index f275436..f06217b 100644 --- a/offlineimap/folder/Maildir.py +++ b/offlineimap/folder/Maildir.py @@ -270,7 +270,7 @@ class MaildirFolder(BaseFolder): filepath = os.path.join(self.getfullname(), filename) return os.path.getmtime(filepath) - def new_message_filename(self, uid, flags=set(), date=None): + def new_message_filename(self, uid, flags=None, date=None): """Creates a new unique Maildir filename :param uid: The UID`None`, or a set of maildir flags @@ -278,6 +278,9 @@ class MaildirFolder(BaseFolder): :param flags: (optional) Date :returns: String containing unique message filename""" + if flags is None: + flags = set() + timeval, timeseq = _gettimeseq(date) uniq_name = '%d_%d.%d.%s,U=%d,FMD5=%s%s2,%s' % \ (timeval, timeseq, os.getpid(), socket.gethostname(),