[Python-checkins] cpython (3.5): Fixed #27251: corrected string/bytes handling in credentials.

vinay.sajip python-checkins at python.org
Tue Jun 7 16:20:59 EDT 2016


https://hg.python.org/cpython/rev/11ebd14076b4
changeset:   101780:11ebd14076b4
branch:      3.5
parent:      101778:b941282513a3
user:        Vinay Sajip <vinay_sajip at yahoo.co.uk>
date:        Tue Jun 07 21:19:55 2016 +0100
summary:
  Fixed #27251: corrected string/bytes handling in credentials.

files:
  Lib/logging/handlers.py  |  4 ++--
  Lib/test/test_logging.py |  3 ++-
  2 files changed, 4 insertions(+), 3 deletions(-)


diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -1156,8 +1156,8 @@
                 h.putheader("Content-length", str(len(data)))
             if self.credentials:
                 import base64
-                s = ('u%s:%s' % self.credentials).encode('utf-8')
-                s = 'Basic ' + base64.b64encode(s).strip()
+                s = ('%s:%s' % self.credentials).encode('utf-8')
+                s = 'Basic ' + base64.b64encode(s).strip().decode('ascii')
                 h.putheader('Authorization', s)
             h.endheaders()
             if self.method == "POST":
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -1672,7 +1672,8 @@
             secure_client = secure and sslctx
             self.h_hdlr = logging.handlers.HTTPHandler(host, '/frob',
                                                        secure=secure_client,
-                                                       context=context)
+                                                       context=context,
+                                                       credentials=('foo', 'bar'))
             self.log_data = None
             root_logger.addHandler(self.h_hdlr)
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list