diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2016-06-07 21:19:55 +0100 |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2016-06-07 21:19:55 +0100 |
commit | 73b426a6a966c192e20c7a720be2d45a51f6f019 (patch) | |
tree | 480d2f802ebc1eb234685c042e4ad2fb45d10815 | |
parent | 72764272b2d8984fa584c312632329e9ad3c9913 (diff) | |
download | cpython-73b426a6a966c192e20c7a720be2d45a51f6f019.tar.gz |
Fixed #27251: corrected string/bytes handling in credentials.
-rw-r--r-- | Lib/logging/handlers.py | 4 | ||||
-rw-r--r-- | 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 index c6840c30b3..c9f8217b06 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -1156,8 +1156,8 @@ class HTTPHandler(logging.Handler): 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 index 95575bf56a..84fd8b57c7 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -1672,7 +1672,8 @@ class HTTPHandlerTest(BaseTest): 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) |