From c12199bafd156c72e183ad2b3a500d4223753121 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 11 Jan 2017 12:15:28 +0000 Subject: [PATCH] fix to_bytes_2and3 breakage on 2.7 --- jws/utils.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/jws/utils.py b/jws/utils.py index 091adf4..3f1b981 100644 --- a/jws/utils.py +++ b/jws/utils.py @@ -11,10 +11,8 @@ text_type = str binary_type = bytes -def to_bytes_2and3(s): - if type(s) != binary_type: - s = bytes(s, 'UTF-8') - return s +def to_bytes_2and3(s, encoding='UTF-8'): + return s if isinstance(s, bytes) else s.encode(encoding) def base64url_decode(input): input = to_bytes_2and3(input)