]> granicus.if.org Git - python/commitdiff
Fixed #7552: fixed distutils.command.upload failure on very long passwords
authorTarek Ziadé <ziade.tarek@gmail.com>
Sun, 20 Dec 2009 23:23:34 +0000 (23:23 +0000)
committerTarek Ziadé <ziade.tarek@gmail.com>
Sun, 20 Dec 2009 23:23:34 +0000 (23:23 +0000)
Lib/distutils/command/upload.py
Lib/distutils/tests/test_upload.py
Misc/NEWS

index 8114feb8f2eabb16b9880a34b0bcf4468784fa60..5d6ebcfa4cb78215e5e361bcb3d3061208329164 100644 (file)
@@ -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'
index 0d95a0917eb231af9a8f4c7e1674f2952cb81701..8f6701cc9bdbc55961c936ebf19476cde6a9e5ff 100644 (file)
@@ -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)
index e9d1a5174032b260d15a3e43c4ed9d0651ce9c5e..3c407e0c2b274983ded48e80dccf8930df8b0fbc 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -24,7 +24,11 @@ Core and Builtins
 Library
 -------
 
-- Issue #7231: urllib2 cannot handle https with proxy requiring auth. 
+- 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 Tatsuhiro Tsujikawa.
 
 - Issue #7349: Make methods of file objects in the io module accept None as an
@@ -42,7 +46,7 @@ Library
 - Issue #5949: fixed IMAP4_SSL hang when the IMAP server response is
   missing proper end-of-line termination.
 
-- Issue #7457: added a read_pkg_file method to 
+- Issue #7457: added a read_pkg_file method to
   distutils.dist.DistributionMetadata.
 
 
@@ -560,7 +564,7 @@ Library
 - logging: Added optional `secure` parameter to SMTPHandler, to enable use of
   TLS with authentication credentials.
 
-- Issue #1923: Fixed the removal of meaningful spaces when PKG-INFO is 
+- Issue #1923: Fixed the removal of meaningful spaces when PKG-INFO is
   generated in Distutils. Patch by Stephen Emslie.
 
 - Issue #4120: Drop reference to CRT from manifest when building extensions with
@@ -1764,7 +1768,7 @@ Extension Modules
 Tests
 -----
 
-- Issue #7431: use TESTFN in test_linecache instead of trying to create a 
+- Issue #7431: use TESTFN in test_linecache instead of trying to create a
   file in the Lib/test directory, which might be read-only for the
   user running the tests.