Commit 2ac9671e authored by Tarek Ziadé's avatar Tarek Ziadé

Merged revisions 76954 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r76954 | tarek.ziade | 2009-12-21 01:02:20 +0100 (Mon, 21 Dec 2009) | 9 lines

  Merged revisions 76952 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r76952 | tarek.ziade | 2009-12-21 00:23:34 +0100 (Mon, 21 Dec 2009) | 1 line

    Fixed #7552: fixed distutils.command.upload failure on very long passwords
  ........
................
parent d02bbf71
...@@ -12,7 +12,7 @@ import socket ...@@ -12,7 +12,7 @@ import socket
import platform import platform
import configparser import configparser
import http.client as httpclient import http.client as httpclient
import base64 from base64 import standard_b64encode
import urllib.parse import urllib.parse
# this keeps compatibility for 2.3 and 2.4 # this keeps compatibility for 2.3 and 2.4
...@@ -127,7 +127,7 @@ class upload(PyPIRCCommand): ...@@ -127,7 +127,7 @@ class upload(PyPIRCCommand):
user_pass = (self.username + ":" + self.password).encode('ascii') user_pass = (self.username + ":" + self.password).encode('ascii')
# The exact encoding of the authentication string is debated. # The exact encoding of the authentication string is debated.
# Anyway PyPI only accepts ascii for both username or password. # Anyway PyPI only accepts ascii for both username or password.
auth = "Basic " + base64.encodebytes(user_pass).strip().decode('ascii') auth = "Basic " + standard_b64encode(user_pass).decode('ascii')
# Build up the MIME payload for the POST data # Build up the MIME payload for the POST data
boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254' boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
......
...@@ -10,6 +10,25 @@ from distutils.core import Distribution ...@@ -10,6 +10,25 @@ from distutils.core import Distribution
from distutils.tests import support from distutils.tests import support
from distutils.tests.test_config import PYPIRC, PyPIRCCommandTestCase from distutils.tests.test_config import PYPIRC, PyPIRCCommandTestCase
PYPIRC_LONG_PASSWORD = """\
[distutils]
index-servers =
server1
server2
[server1]
username:me
password:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[server2]
username:meagain
password: secret
realm:acme
repository:http://another.pypi/
"""
PYPIRC_NOPASSWORD = """\ PYPIRC_NOPASSWORD = """\
[distutils] [distutils]
...@@ -96,7 +115,7 @@ class uploadTestCase(PyPIRCCommandTestCase): ...@@ -96,7 +115,7 @@ class uploadTestCase(PyPIRCCommandTestCase):
self.write_file(path) self.write_file(path)
command, pyversion, filename = 'xxx', '2.6', path command, pyversion, filename = 'xxx', '2.6', path
dist_files = [(command, pyversion, filename)] dist_files = [(command, pyversion, filename)]
self.write_file(self.rc, PYPIRC) self.write_file(self.rc, PYPIRC_LONG_PASSWORD)
# lets run it # lets run it
pkg_dir, dist = self.create_dist(dist_files=dist_files) pkg_dir, dist = self.create_dist(dist_files=dist_files)
...@@ -108,6 +127,7 @@ class uploadTestCase(PyPIRCCommandTestCase): ...@@ -108,6 +127,7 @@ class uploadTestCase(PyPIRCCommandTestCase):
headers = dict(self.conn.headers) headers = dict(self.conn.headers)
self.assertEquals(headers['Content-length'], '2087') self.assertEquals(headers['Content-length'], '2087')
self.assertTrue(headers['Content-type'].startswith('multipart/form-data')) self.assertTrue(headers['Content-type'].startswith('multipart/form-data'))
self.assertFalse('\n' in headers['Authorization'])
self.assertEquals(self.conn.requests, [('POST', '/pypi')]) self.assertEquals(self.conn.requests, [('POST', '/pypi')])
self.assert_((b'xxx') in self.conn.body) self.assert_((b'xxx') in self.conn.body)
......
...@@ -58,6 +58,10 @@ Core and Builtins ...@@ -58,6 +58,10 @@ Core and Builtins
Library Library
------- -------
- Issue #7552: Removed line feed in the base64 Authorization header in
the Distutils upload command to avoid an error when PyPI reads it.
This occurs on long passwords. Initial patch by JP St. Pierre.
- Issue #7231: urllib2 cannot handle https with proxy requiring auth. Patch by - Issue #7231: urllib2 cannot handle https with proxy requiring auth. Patch by
Tatsuhiro Tsujikawa. Tatsuhiro Tsujikawa.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment