22import hashlib
33import logging
44import json
5- import six
6- import sys
75
86from cryptography import x509
97
2119from cryptojwt import b64d
2220from cryptojwt import b64e
2321from cryptojwt import long_to_base64
24- from cryptojwt .exception import UnknownAlgorithm , JWKException , HeaderError , \
25- JWKESTException
22+ from cryptojwt .exception import HeaderError
23+ from cryptojwt .exception import JWKESTException
24+ from cryptojwt .exception import JWKException
25+ from cryptojwt .exception import UnknownAlgorithm
2626from cryptojwt .exception import DeSerializationNotPossible
2727from cryptojwt .exception import SerializationNotPossible
2828
29- if sys .version > '3' :
30- long = int
31- else :
32- from __builtin__ import long
33-
34- __author__ = 'rohe0002'
29+ __author__ = 'roland hedberg'
3530
3631logger = logging .getLogger (__name__ )
3732
@@ -334,22 +329,22 @@ def __init__(self, kty="", alg="", use="", kid="", key=None, x5c=None,
334329 self .extra_args = kwargs
335330
336331 # want kty, alg, use and kid to be strings
337- if isinstance (kty , six . string_types ):
332+ if isinstance (kty , str ):
338333 self .kty = kty
339334 else :
340335 self .kty = as_unicode (kty )
341336
342- if isinstance (alg , six . string_types ):
337+ if isinstance (alg , str ):
343338 self .alg = alg
344339 else :
345340 self .alg = as_unicode (alg )
346341
347- if isinstance (use , six . string_types ):
342+ if isinstance (use , str ):
348343 self .use = use
349344 else :
350345 self .use = as_unicode (use )
351346
352- if isinstance (kid , six . string_types ):
347+ if isinstance (kid , str ):
353348 self .kid = kid
354349 else :
355350 self .kid = as_unicode (kid )
@@ -438,7 +433,7 @@ def verify(self):
438433 return False
439434
440435 if self .kid :
441- if not isinstance (self .kid , six . string_types ):
436+ if not isinstance (self .kid , str ):
442437 raise HeaderError ("kid of wrong value type" )
443438 return True
444439
@@ -449,9 +444,8 @@ def __eq__(self, other):
449444 :param other: The other Key instance
450445 :return: True if they are the same otherwise False.
451446 """
452- try :
453- if self .__class__ != other .__class__ :
454- return False
447+ if self .__class__ != other .__class__ :
448+ return False
455449
456450 if set (self .__dict__ .keys ()) != set (other .__dict__ .keys ()):
457451 return False
@@ -635,7 +629,7 @@ def deserialize(self):
635629 continue
636630 else :
637631 try :
638- val = long (deser (item ))
632+ val = int (deser (item ))
639633 except Exception :
640634 raise
641635 else :
0 commit comments