BUG: Right format for host using remotehosteval
Similarly to 7a428537
, reading the host
using remotehosteval returns a bytes objects instead an utf-8 string.
This patch includes support for both string and bytes objects.
This commit is contained in:
parent
896ac98984
commit
c21a7fa0a3
@ -141,7 +141,21 @@ class IMAPRepository(BaseRepository):
|
|||||||
if self.config.has_option(self.getsection(), 'remotehosteval'):
|
if self.config.has_option(self.getsection(), 'remotehosteval'):
|
||||||
host = self.getconf('remotehosteval')
|
host = self.getconf('remotehosteval')
|
||||||
try:
|
try:
|
||||||
host = self.localeval.eval(host)
|
l_host = self.localeval.eval(host)
|
||||||
|
|
||||||
|
# We need a str host
|
||||||
|
if isinstance(l_host, bytes):
|
||||||
|
return l_host.decode(encoding='utf-8')
|
||||||
|
elif isinstance(l_host, str):
|
||||||
|
return l_host
|
||||||
|
|
||||||
|
# If is not bytes or str, we have a problem
|
||||||
|
raise OfflineImapError("Could not get a right host format for"
|
||||||
|
" repository %s. Type found: %s. "
|
||||||
|
"Please, open a bug." %
|
||||||
|
(self.name, type(l_host)),
|
||||||
|
OfflineImapError.ERROR.FOLDER)
|
||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
raise OfflineImapError(
|
raise OfflineImapError(
|
||||||
"remotehosteval option for repository "
|
"remotehosteval option for repository "
|
||||||
|
Loading…
Reference in New Issue
Block a user