Merge ~cjwatson/launchpad:py3-fix-fileuploadprotocol into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 3e9c63cd0fa56cd5e1d90dea656e17a39d29287a
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-fix-fileuploadprotocol
Merge into: launchpad:master
Diff against target: 29 lines (+2/-3)
1 file modified
lib/lp/services/librarianserver/libraryprotocol.py (+2/-3)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+395293@code.launchpad.net

Commit message

Remove excessive decoding from FileUploadProtocol

Description of the change

Broken by 2d3fa6f225bea7b4c2393810454cca10439027b7, because lineReceived now decodes the line first so we shouldn't decode it again later. We get away with this on Python 2 because (confusingly) it's usually possible to decode a unicode object there as long as it only contains ASCII, but Python 3 is stricter.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/services/librarianserver/libraryprotocol.py b/lib/lp/services/librarianserver/libraryprotocol.py
2index 6a8d61d..5d49257 100644
3--- a/lib/lp/services/librarianserver/libraryprotocol.py
4+++ b/lib/lp/services/librarianserver/libraryprotocol.py
5@@ -111,7 +111,6 @@ class FileUploadProtocol(basic.LineReceiver):
6 def line_command(self, line):
7 try:
8 command, args = line.split(None, 1)
9- command = command.decode('UTF-8')
10 except ValueError:
11 raise ProtocolViolation('Bad command: ' + line)
12
13@@ -120,7 +119,7 @@ class FileUploadProtocol(basic.LineReceiver):
14
15 def line_header(self, line):
16 # Blank line signals the end of the headers
17- if line == b'':
18+ if line == '':
19 # If File-Content-ID was specified, File-Alias-ID must be too, and
20 # vice-versa.
21 contentID = self.newFile.contentID
22@@ -147,7 +146,7 @@ class FileUploadProtocol(basic.LineReceiver):
23
24 # Simple RFC 822-ish header parsing
25 try:
26- name, value = line.decode('UTF-8').split(':', 2)
27+ name, value = line.split(':', 2)
28 except ValueError:
29 raise ProtocolViolation('Invalid header: ' + line)
30

Subscribers

People subscribed via source and target branches

to status/vote changes: