From 5e356b0bf57beb04e79b11552ab262003ad6a7ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Fri, 28 Aug 2020 12:38:15 +0200 Subject: [PATCH] Removed codecs I removed these calls to codecs because I got the error: ValueError: can't have text and binary mode at once --- offlineimap/mbnames.py | 13 ++++++------- offlineimap/repository/IMAP.py | 5 ++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/offlineimap/mbnames.py b/offlineimap/mbnames.py index 0d38e72..756dc0f 100644 --- a/offlineimap/mbnames.py +++ b/offlineimap/mbnames.py @@ -16,7 +16,6 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -import codecs import re # For folderfilter. import json from threading import Lock @@ -120,8 +119,8 @@ class _IntermediateMbnames(object): if self._dryrun: self.ui.info("mbnames would write %s"% self._path) else: - with codecs.open( - self._path, "wt", encoding='UTF-8') as intermediateFD: + with open( + self._path, "w", encoding='utf-8') as intermediateFD: json.dump(itemlist, intermediateFD) @@ -235,8 +234,8 @@ class _Mbnames(object): for intermediateFile in self._iterIntermediateFiles(): try: - with codecs.open( - intermediateFile, 'rt', encoding="UTF-8") as intermediateFD: + with open( + intermediateFile, 'r', encoding="utf-8") as intermediateFD: for item in json.load(intermediateFD): itemlist.append(item) except (OSError, IOError) as e: @@ -257,8 +256,8 @@ class _Mbnames(object): self.ui.info("mbnames would write %s"% self._path) else: try: - with codecs.open( - self._path, 'wt', encoding='UTF-8') as mbnamesFile: + with open( + self._path, 'w', encoding='utf-8') as mbnamesFile: mbnamesFile.write(self._header) mbnamesFile.write(self._sep.join(itemlist)) mbnamesFile.write(self._footer) diff --git a/offlineimap/repository/IMAP.py b/offlineimap/repository/IMAP.py index 1f5c855..829741d 100644 --- a/offlineimap/repository/IMAP.py +++ b/offlineimap/repository/IMAP.py @@ -19,7 +19,6 @@ import os import netrc import errno -import codecs from sys import exc_info from threading import Event @@ -389,7 +388,7 @@ class IMAPRepository(BaseRepository): # 1. Evaluate Repository 'remotepasseval'. passwd = self.getconf('remotepasseval', None) if passwd is not None: - return self.localeval.eval(passwd).encode('UTF-8') + return self.localeval.eval(passwd).encode('utf-8') # 2. Read password from Repository 'remotepass'. password = self.getconf('remotepass', None) if password is not None: @@ -399,7 +398,7 @@ class IMAPRepository(BaseRepository): # 3. Read password from file specified in Repository 'remotepassfile'. passfile = self.getconf('remotepassfile', None) if passfile is not None: - fd = codecs.open(os.path.expanduser(passfile), 'r', 'UTF-8') + fd = open(os.path.expanduser(passfile), 'r', 'utf-8') password = fd.readline().strip() fd.close() return password.encode('UTF-8')