launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25853
[Merge] ~cjwatson/launchpad:py3-fix-fileuploadprotocol into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-fix-fileuploadprotocol into launchpad:master.
Commit message:
Remove excessive decoding from FileUploadProtocol
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/395293
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.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-fix-fileuploadprotocol into launchpad:master.
diff --git a/lib/lp/services/librarianserver/libraryprotocol.py b/lib/lp/services/librarianserver/libraryprotocol.py
index 6a8d61d..5d49257 100644
--- a/lib/lp/services/librarianserver/libraryprotocol.py
+++ b/lib/lp/services/librarianserver/libraryprotocol.py
@@ -111,7 +111,6 @@ class FileUploadProtocol(basic.LineReceiver):
def line_command(self, line):
try:
command, args = line.split(None, 1)
- command = command.decode('UTF-8')
except ValueError:
raise ProtocolViolation('Bad command: ' + line)
@@ -120,7 +119,7 @@ class FileUploadProtocol(basic.LineReceiver):
def line_header(self, line):
# Blank line signals the end of the headers
- if line == b'':
+ if line == '':
# If File-Content-ID was specified, File-Alias-ID must be too, and
# vice-versa.
contentID = self.newFile.contentID
@@ -147,7 +146,7 @@ class FileUploadProtocol(basic.LineReceiver):
# Simple RFC 822-ish header parsing
try:
- name, value = line.decode('UTF-8').split(':', 2)
+ name, value = line.split(':', 2)
except ValueError:
raise ProtocolViolation('Invalid header: ' + line)