diff --git a/requests/auth.py b/requests/auth.py index bd2fe7d8..701104d0 100644 --- a/requests/auth.py +++ b/requests/auth.py @@ -12,6 +12,7 @@ import re import time import hashlib import threading +import warnings from base64 import b64encode @@ -36,9 +37,23 @@ def _basic_auth_str(username, password): # These are here solely to maintain backwards compatibility # for things like ints. This will be removed in 3.0.0. if not isinstance(username, basestring): + warnings.warn( + "Non-string usernames will no longer be supported in Requests " + "3.0.0. Please convert the object you've passed in ({!r}) to " + "a string or bytes object in the near future to avoid " + "problems.".format(username), + category=DeprecationWarning, + ) username = str(username) if not isinstance(password, basestring): + warnings.warn( + "Non-string passwords will no longer be supported in Requests " + "3.0.0. Please convert the object you've passed in ({!r}) to " + "a string or bytes object in the near future to avoid " + "problems.".format(password), + category=DeprecationWarning, + ) password = str(password) # -- End Removal -- diff --git a/tests/test_requests.py b/tests/test_requests.py index b94e0fa2..70564d26 100755 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -514,7 +514,8 @@ class TestRequests: 'username, password', ( ('user', 'pass'), (u'имя'.encode('utf-8'), u'пароль'.encode('utf-8')), - (42, 42) + (42, 42), + (None, None), )) def test_set_basicauth(self, httpbin, username, password): auth = (username, password)