Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4)

Unified Diff: Lib/packaging/command/upload.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/packaging/command/upload_docs.py ('k') | Lib/packaging/database.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/packaging/command/upload.py Tue Jul 26 09:37:46 2011 +0300
+++ b/Lib/packaging/command/upload.py Mon Jul 25 09:47:18 2011 -0400
@@ -14,7 +14,7 @@
from packaging import logger
from packaging.errors import PackagingOptionError
from packaging.util import (spawn, read_pypirc, DEFAULT_REPOSITORY,
- DEFAULT_REALM, encode_multipart)
+ DEFAULT_REALM)
from packaging.command.cmd import Command
@@ -131,22 +131,54 @@
auth = b"Basic " + standard_b64encode(user_pass)
# Build up the MIME payload for the POST data
- files = []
- for key in ('content', 'gpg_signature'):
- if key in data:
- filename_, value = data.pop(key)
- files.append((key, filename_, value))
+ boundary = b'--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
+ sep_boundary = b'\n--' + boundary
+ end_boundary = sep_boundary + b'--'
+ body = BytesIO()
- content_type, body = encode_multipart(data.items(), files)
+ file_fields = ('content', 'gpg_signature')
+
+ for key, value in data.items():
+ # handle multiple entries for the same name
+ if not isinstance(value, tuple):
+ value = [value]
+
+ content_dispo = '\nContent-Disposition: form-data; name="%s"' % key
+
+ if key in file_fields:
+ filename_, content = value
+ filename_ = ';filename="%s"' % filename_
+ body.write(sep_boundary)
+ body.write(content_dispo.encode('utf-8'))
+ body.write(filename_.encode('utf-8'))
+ body.write(b"\n\n")
+ body.write(content)
+ else:
+ for value in value:
+ value = str(value).encode('utf-8')
+ body.write(sep_boundary)
+ body.write(content_dispo.encode('utf-8'))
+ body.write(b"\n\n")
+ body.write(value)
+ if value and value.endswith(b'\r'):
+ # write an extra newline (lurve Macs)
+ body.write(b'\n')
+
+ body.write(end_boundary)
+ body.write(b"\n")
+ body = body.getvalue()
logger.info("Submitting %s to %s", filename, self.repository)
# build the Request
- headers = {'Content-type': content_type,
+ headers = {'Content-type':
+ 'multipart/form-data; boundary=%s' %
+ boundary.decode('ascii'),
'Content-length': str(len(body)),
'Authorization': auth}
- request = Request(self.repository, body, headers)
+ request = Request(self.repository, data=body,
+ headers=headers)
# send the data
try:
result = urlopen(request)
« no previous file with comments | « Lib/packaging/command/upload_docs.py ('k') | Lib/packaging/database.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+