[Patchew-devel] [PATCH] Defines exception handled at get_mbox_with_tags
Caio Carrara
ccarrara at redhat.com
Wed Nov 28 18:19:14 UTC 2018
When using try..except statement the exception must always be specified
instead of using a bare except. It's a recommendation from PEP8 quoted
below:
A bare except: clause will catch SystemExit and KeyboardInterrupt
exceptions, making it harder to interrupt a program with Control-C, and
can disguise other problems. If you want to catch all exceptions that
signal program errors, use except Exception: (bare except is equivalent
to except BaseException:)[1]
[1] - https://www.python.org/dev/peps/pep-0008/
Signed-off-by: Caio Carrara <ccarrara at redhat.com>
---
www/views.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/www/views.py b/www/views.py
index 2aae127..89a8127 100644
--- a/www/views.py
+++ b/www/views.py
@@ -297,7 +297,7 @@ def view_mbox(request, project, message_id):
# patches, quoted-printable is safe and mostly human-readable.
try:
container.replace_header('Content-Transfer-Encoding', 'quoted-printable')
- except:
+ except KeyError:
msg.add_header('Content-Transfer-Encoding', 'quoted-printable')
payload = '\n'.join(mbox_with_tags_iter(payload, m.tags))
payload = quopri.encodestring(payload.encode('utf-8'))
--
2.19.2
More information about the Patchew-devel
mailing list