Merge ~cjwatson/launchpad:py3-base64-exception into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 5e95c52da01efb4f3e4c598446e399621c57c8c8
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-base64-exception
Merge into: launchpad:master
Diff against target: 23 lines (+4/-1)
1 file modified
lib/lp/code/browser/gitrepository.py (+4/-1)
Reviewer Review Type Date Requested Status
Cristian Gonzalez (community) Approve
Review via email: mp+398984@code.launchpad.net

Commit message

Handle different exception raised by base64 on Python 3

To post a comment you must log in.
Revision history for this message
Cristian Gonzalez (cristiangsp) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/code/browser/gitrepository.py b/lib/lp/code/browser/gitrepository.py
2index 31f7a14..76606cd 100644
3--- a/lib/lp/code/browser/gitrepository.py
4+++ b/lib/lp/code/browser/gitrepository.py
5@@ -23,6 +23,7 @@ __all__ = [
6 ]
7
8 import base64
9+import binascii
10 from collections import defaultdict
11
12 from breezy import urlutils
13@@ -990,7 +991,9 @@ class GitRepositoryPermissionsView(LaunchpadFormView):
14 field_type = field_bits[0]
15 try:
16 ref_pattern = decode_form_field_id(field_bits[1])
17- except TypeError:
18+ # base64.b32decode raises TypeError for decoding errors on Python 2,
19+ # but binascii.Error on Python 3.
20+ except (TypeError, binascii.Error):
21 raise UnexpectedFormData(
22 "Cannot parse field name: %s" % field_name)
23 if len(field_bits) > 2:

Subscribers

People subscribed via source and target branches

to status/vote changes: