From: R David Murray Date: Sat, 27 Sep 2014 20:57:51 +0000 (-0400) Subject: Merge: #10510: make distuitls upload/register use HTML standards compliant CRLF. X-Git-Tag: v3.5.0a1~836 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3a54c3e3aa7148522ca1af7244b79f9bad57c59b;p=python Merge: #10510: make distuitls upload/register use HTML standards compliant CRLF. --- 3a54c3e3aa7148522ca1af7244b79f9bad57c59b diff --cc Lib/distutils/command/upload.py index 1fdb456a6d,9b15b67bae..e3f6f69607 --- a/Lib/distutils/command/upload.py +++ b/Lib/distutils/command/upload.py @@@ -141,13 -143,13 +141,13 @@@ class upload(PyPIRCCommand) # Build up the MIME payload for the POST data boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254' - sep_boundary = b'\n--' + boundary.encode('ascii') - end_boundary = sep_boundary + b'--' + sep_boundary = b'\r\n--' + boundary.encode('ascii') + end_boundary = sep_boundary + b'--\r\n' body = io.BytesIO() for key, value in data.items(): - title = '\nContent-Disposition: form-data; name="%s"' % key + title = '\r\nContent-Disposition: form-data; name="%s"' % key # handle multiple entries for the same name - if type(value) != type([]): + if not isinstance(value, list): value = [value] for value in value: if type(value) is tuple: @@@ -162,18 -164,16 +162,18 @@@ if value and value[-1:] == b'\r': body.write(b'\n') # write an extra newline (lurve Macs) body.write(end_boundary) - body.write(b"\n") + body.write(b"\r\n") body = body.getvalue() - self.announce("Submitting %s to %s" % (filename, self.repository), log.INFO) + msg = "Submitting %s to %s" % (filename, self.repository) + self.announce(msg, log.INFO) # build the Request - headers = {'Content-type': - 'multipart/form-data; boundary=%s' % boundary, - 'Content-length': str(len(body)), - 'Authorization': auth} + headers = { + 'Content-type': 'multipart/form-data; boundary=%s' % boundary, + 'Content-length': str(len(body)), + 'Authorization': auth, + } request = Request(self.repository, data=body, headers=headers)