Package: offlineimap3 Version: 0.0~git20210105.00d395b+dfsg-3 Severity: important
Dear Maintainer, offlineimap fails with: sequence item 1: expected str instance, bytes found while trying to sync an imap folder with pythonfile = ~/.config/offlineimap.py that looks up username and password: remoteusereval = get_username("account") while get_username returns a string, the value gets converted into bytes in /usr/share/offlineimap3/offlineimap/repository/IMAP.py ... def getuser(self): ... if user is not None: return localeval.eval(user).encode('UTF-8') due to that, the following fails: /usr/share/offlineimap3/offlineimap/imapserver.py ... def __plainhandler(self, response): tries to mix bytes and strings: retval = NULL.join((authz, authc, passwd)) This has been fixed upstream in https://github.com/OfflineIMAP/offlineimap3/pull/50 in the same way it was fixed for passwords in debian/patches/0001-Right-format-for-password-from-remotepassfile.patch -- System Information: Debian Release: bullseye/sid APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 5.10.0-3-amd64 (SMP w/8 CPU threads) Kernel taint flags: TAINT_WARN, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages offlineimap3 depends on: ii python3 3.9.1-1 ii python3-distro 1.5.0-1 ii python3-imaplib2 2.57-5.2 offlineimap3 recommends no packages. offlineimap3 suggests no packages. -- no debconf information
>From fa080b8d92944a1692a44e982292ffde8066950a Mon Sep 17 00:00:00 2001 From: Konstantinos Natsakis <5933427+knatsa...@users.noreply.github.com> Date: Mon, 8 Feb 2021 23:40:32 +0200 Subject: [PATCH] BUG: Right format for username using remoteusereval Similarly to 7a4285370f338a6653e8bb1a8fb99e3703683b6f, reading the username using remoteusereval returns a bytes objects instead an utf-8 string. This patch includes support for both string and bytes objects. Signed-off-by: Konstantinos Natsakis <5933427+knatsa...@users.noreply.github.com> --- offlineimap/repository/IMAP.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/offlineimap/repository/IMAP.py b/offlineimap/repository/IMAP.py index b732243..e90d30c 100644 --- a/offlineimap/repository/IMAP.py +++ b/offlineimap/repository/IMAP.py @@ -206,12 +206,23 @@ def getuser(self): Returns: Returns the remoteusereval or remoteuser or netrc user value. """ - localeval = self.localeval - if self.config.has_option(self.getsection(), 'remoteusereval'): user = self.getconf('remoteusereval') if user is not None: - return localeval.eval(user).encode('UTF-8') + l_user = self.localeval.eval(user) + + # We need a str username + if isinstance(l_user, bytes): + return l_user.decode(encoding='utf-8') + elif isinstance(l_user, str): + return l_user + + # If is not bytes or str, we have a problem + raise OfflineImapError("Could not get a right username format for" + " repository %s. Type found: %s. " + "Please, open a bug." % + (self.name, type(l_user)), + OfflineImapError.ERROR.FOLDER) if self.config.has_option(self.getsection(), 'remoteuser'): # Assume the configuration file to be UTF-8 encoded so we must not