1
- import six
2
-
3
1
from gssapi .raw import names as rname
4
2
from gssapi .raw import NameType
5
3
from gssapi .raw import named_tuples as tuples
6
4
from gssapi import _utils
7
5
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
12
7
13
8
14
9
rname_rfc6680 = _utils .import_gssapi_extension ('rfc6680' )
@@ -69,7 +64,7 @@ def __new__(cls, base=None, name_type=None, token=None,
69
64
elif isinstance (base , rname .Name ):
70
65
base_name = base
71
66
else :
72
- if isinstance (base , six . text_type ):
67
+ if isinstance (base , str ):
73
68
base = base .encode (_utils ._get_encoding ())
74
69
75
70
base_name = rname .import_name (base , name_type )
@@ -107,12 +102,7 @@ def __init__(self, base=None, name_type=None, token=None, composite=False):
107
102
self ._attr_obj = None
108
103
109
104
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 ())
116
106
117
107
def __unicode__ (self ):
118
108
# Python 2 -- someone asked for unicode
@@ -324,7 +314,7 @@ def __init__(self, name):
324
314
self ._name = name
325
315
326
316
def __getitem__ (self , key ):
327
- if isinstance (key , six . text_type ):
317
+ if isinstance (key , str ):
328
318
key = key .encode (_utils ._get_encoding ())
329
319
330
320
res = rname_rfc6680 .get_name_attribute (self ._name , key )
@@ -334,7 +324,7 @@ def __getitem__(self, key):
334
324
res .complete )
335
325
336
326
def __setitem__ (self , key , value ):
337
- if isinstance (key , six . text_type ):
327
+ if isinstance (key , str ):
338
328
key = key .encode (_utils ._get_encoding ())
339
329
340
330
rname_rfc6680 .delete_name_attribute (self ._name , key )
@@ -348,7 +338,7 @@ def __setitem__(self, key, value):
348
338
else :
349
339
complete = False
350
340
351
- if (isinstance (value , (six . string_types , bytes )) or
341
+ if (isinstance (value , (str , bytes )) or
352
342
not isinstance (value , Iterable )):
353
343
# NB(directxman12): this allows us to easily assign a single
354
344
# value, since that's a common case
@@ -358,7 +348,7 @@ def __setitem__(self, key, value):
358
348
complete = complete )
359
349
360
350
def __delitem__ (self , key ):
361
- if isinstance (key , six . text_type ):
351
+ if isinstance (key , str ):
362
352
key = key .encode (_utils ._get_encoding ())
363
353
364
354
rname_rfc6680 .delete_name_attribute (self ._name , key )
0 commit comments