From 329a5cfdd4500fb1ce405a3242ef95f9197d24ba Mon Sep 17 00:00:00 2001 From: Dmitry Klimenko Date: Thu, 17 Nov 2016 19:50:53 +0300 Subject: [PATCH] Order of type check --- requests/auth.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/requests/auth.py b/requests/auth.py index 057d723e..20b9883c 100644 --- a/requests/auth.py +++ b/requests/auth.py @@ -28,14 +28,14 @@ CONTENT_TYPE_MULTI_PART = 'multipart/form-data' def _basic_auth_str(username, password): """Returns a Basic Auth string.""" - if isinstance(username, bytes): - username = username.decode('latin1') + if isinstance(username, str): + username = username.encode('latin1') - if isinstance(password, bytes): - password = password.decode('latin1') + if isinstance(password, str): + password = password.encode('latin1') authstr = 'Basic ' + to_native_string( - b64encode(('%s:%s' % (username, password)).encode('latin1')).strip() + b64encode(b':'.join((username, password))).strip() ) return authstr