Fix unicode under Python 2
@@ -81,8 +81,11 @@ def basic_auth(realm, checkpassword, debug=False, accept_charset='utf-8'):
scheme, params = auth_header.split(' ', 1)
if scheme.lower() == 'basic':
decoded_params = base64_decode(params)
- decoded_params = tonative(ntob(decoded_params), accept_charset)
+ decoded_params = ntou(
+ tonative(ntob(decoded_params), accept_charset)
+ )
decoded_params = unicodedata.normalize('NFC', decoded_params)
+ decoded_params = tonative(decoded_params)
username, password = decoded_params.split(':', 1)
if checkpassword(realm, username, password):
if debug:
