From d75b4f5e612b4e38caf656a5151209e356d6d5c3 Mon Sep 17 00:00:00 2001 From: rstewart2702 Date: Thu, 29 Jul 2021 12:24:57 -0500 Subject: [PATCH 1/3] The data returned by the list_folders method is a list of three-tuples. The data in each three tuple are extracted by the iteration in the program into: flags, a tuple or iterable of bytestrings delimiter, a bytestring folder_name, an encoded string (Unicode, according to the Python3 standard) This change adds code to invoke the bytestring type's decode method, which is necessary to convert the bytestring data into Unicode data acceptable in the later incarnations of Python. --- py3/chapter15/open_imap.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/py3/chapter15/open_imap.py b/py3/chapter15/open_imap.py index 17a6d33..825c055 100644 --- a/py3/chapter15/open_imap.py +++ b/py3/chapter15/open_imap.py @@ -22,7 +22,10 @@ def main(): print('Listing mailboxes:') data = c.list_folders() for flags, delimiter, folder_name in data: - print(' %-30s%s %s' % (' '.join(flags), delimiter, folder_name)) + print(' %-30s%s %s' % + ( ( b' '.join(flags) ).decode() , + delimiter.decode() , + folder_name ) ) finally: c.logout() From 1259462967210421ed93c5946e4b831e6484e701 Mon Sep 17 00:00:00 2001 From: rstewart2702 Date: Thu, 29 Jul 2021 17:42:43 -0500 Subject: [PATCH 2/3] This change also works (PEP 461 was a helpful read...) --- py3/chapter15/open_imap.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/py3/chapter15/open_imap.py b/py3/chapter15/open_imap.py index 825c055..c464a78 100644 --- a/py3/chapter15/open_imap.py +++ b/py3/chapter15/open_imap.py @@ -22,10 +22,7 @@ def main(): print('Listing mailboxes:') data = c.list_folders() for flags, delimiter, folder_name in data: - print(' %-30s%s %s' % - ( ( b' '.join(flags) ).decode() , - delimiter.decode() , - folder_name ) ) + print(' %-30s%s %s' % ( b' '.join(flags), delimiter, folder_name ) ) finally: c.logout() From b5b70fd6376f55d0d94db4cd4db56507c34a096f Mon Sep 17 00:00:00 2001 From: rstewart2702 Date: Thu, 29 Jul 2021 17:51:05 -0500 Subject: [PATCH 3/3] Removed extraneous whitespace. --- py3/chapter15/open_imap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py3/chapter15/open_imap.py b/py3/chapter15/open_imap.py index c464a78..fea47ee 100644 --- a/py3/chapter15/open_imap.py +++ b/py3/chapter15/open_imap.py @@ -22,7 +22,7 @@ def main(): print('Listing mailboxes:') data = c.list_folders() for flags, delimiter, folder_name in data: - print(' %-30s%s %s' % ( b' '.join(flags), delimiter, folder_name ) ) + print(' %-30s%s %s' % (b' '.join(flags), delimiter, folder_name)) finally: c.logout()