1- import six
2-
31from gssapi .raw import names as rname
42from gssapi .raw import NameType
53from gssapi .raw import named_tuples as tuples
64from gssapi import _utils
75
8- if six .PY2 :
9- from collections import MutableMapping , Iterable
10- else :
11- from collections .abc import MutableMapping , Iterable
6+ from collections .abc import MutableMapping , Iterable
127
138
149rname_rfc6680 = _utils .import_gssapi_extension ('rfc6680' )
@@ -69,7 +64,7 @@ def __new__(cls, base=None, name_type=None, token=None,
6964 elif isinstance (base , rname .Name ):
7065 base_name = base
7166 else :
72- if isinstance (base , six . text_type ):
67+ if isinstance (base , str ):
7368 base = base .encode (_utils ._get_encoding ())
7469
7570 base_name = rname .import_name (base , name_type )
@@ -107,12 +102,7 @@ def __init__(self, base=None, name_type=None, token=None, composite=False):
107102 self ._attr_obj = None
108103
109104 def __str__ (self ):
110- if issubclass (str , six .text_type ):
111- # Python 3 -- we should return unicode
112- return bytes (self ).decode (_utils ._get_encoding ())
113- else :
114- # Python 2 -- we should return a string
115- return self .__bytes__ ()
105+ return bytes (self ).decode (_utils ._get_encoding ())
116106
117107 def __unicode__ (self ):
118108 # Python 2 -- someone asked for unicode
@@ -324,7 +314,7 @@ def __init__(self, name):
324314 self ._name = name
325315
326316 def __getitem__ (self , key ):
327- if isinstance (key , six . text_type ):
317+ if isinstance (key , str ):
328318 key = key .encode (_utils ._get_encoding ())
329319
330320 res = rname_rfc6680 .get_name_attribute (self ._name , key )
@@ -334,7 +324,7 @@ def __getitem__(self, key):
334324 res .complete )
335325
336326 def __setitem__ (self , key , value ):
337- if isinstance (key , six . text_type ):
327+ if isinstance (key , str ):
338328 key = key .encode (_utils ._get_encoding ())
339329
340330 rname_rfc6680 .delete_name_attribute (self ._name , key )
@@ -348,7 +338,7 @@ def __setitem__(self, key, value):
348338 else :
349339 complete = False
350340
351- if (isinstance (value , (six . string_types , bytes )) or
341+ if (isinstance (value , (str , bytes )) or
352342 not isinstance (value , Iterable )):
353343 # NB(directxman12): this allows us to easily assign a single
354344 # value, since that's a common case
@@ -358,7 +348,7 @@ def __setitem__(self, key, value):
358348 complete = complete )
359349
360350 def __delitem__ (self , key ):
361- if isinstance (key , six . text_type ):
351+ if isinstance (key , str ):
362352 key = key .encode (_utils ._get_encoding ())
363353
364354 rname_rfc6680 .delete_name_attribute (self ._name , key )
0 commit comments