summaryrefslogtreecommitdiffstats
path: root/Lib/distutils
diff options
context:
space:
mode:
authorTarek Ziadé <ziade.tarek@gmail.com>2009-12-20 23:23:34 (GMT)
committerTarek Ziadé <ziade.tarek@gmail.com>2009-12-20 23:23:34 (GMT)
commit2421d56e0205b58b925d1b6534f8ee3505ed549b (patch)
tree4838e2972c110439b96cf88ae7dc8135fdc36898 /Lib/distutils
parent603ae9e371fee4e2f61375cd9738559acacae987 (diff)
downloadcpython-2421d56e0205b58b925d1b6534f8ee3505ed549b.zip
cpython-2421d56e0205b58b925d1b6534f8ee3505ed549b.tar.gz
cpython-2421d56e0205b58b925d1b6534f8ee3505ed549b.tar.bz2
Fixed #7552: fixed distutils.command.upload failure on very long passwords
Diffstat (limited to 'Lib/distutils')
-rw-r--r--Lib/distutils/command/upload.py6
-rw-r--r--Lib/distutils/tests/test_upload.py23
2 files changed, 25 insertions, 4 deletions
diff --git a/Lib/distutils/command/upload.py b/Lib/distutils/command/upload.py
index 8114feb..5d6ebcf 100644
--- a/Lib/distutils/command/upload.py
+++ b/Lib/distutils/command/upload.py
@@ -6,7 +6,7 @@ import os
import socket
import platform
from urllib2 import urlopen, Request, HTTPError
-import base64
+from base64 import standard_b64encode
import urlparse
import cStringIO as StringIO
from ConfigParser import ConfigParser
@@ -129,8 +129,8 @@ class upload(PyPIRCCommand):
open(filename+".asc").read())
# set up the authentication
- auth = "Basic " + base64.encodestring(self.username + ":" +
- self.password).strip()
+ auth = "Basic " + standard_b64encode(self.username + ":" +
+ self.password)
# Build up the MIME payload for the POST data
boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
diff --git a/Lib/distutils/tests/test_upload.py b/Lib/distutils/tests/test_upload.py
index 0d95a09..8f6701c 100644
--- a/Lib/distutils/tests/test_upload.py
+++ b/Lib/distutils/tests/test_upload.py
@@ -10,6 +10,25 @@ from distutils.core import Distribution
from distutils.tests import support
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 = """\
[distutils]
@@ -85,7 +104,7 @@ class uploadTestCase(PyPIRCCommandTestCase):
self.write_file(path)
command, pyversion, filename = 'xxx', '2.6', path
dist_files = [(command, pyversion, filename)]
- self.write_file(self.rc, PYPIRC)
+ self.write_file(self.rc, PYPIRC_LONG_PASSWORD)
# lets run it
pkg_dir, dist = self.create_dist(dist_files=dist_files)
@@ -101,6 +120,8 @@ class uploadTestCase(PyPIRCCommandTestCase):
self.assertEquals(self.last_open.req.get_full_url(),
'http://pypi.python.org/pypi')
self.assertTrue('xxx' in self.last_open.req.data)
+ auth = self.last_open.req.headers['Authorization']
+ self.assertFalse('\n' in auth)
def test_suite():
return unittest.makeSuite(uploadTestCase)