summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2020-04-21 20:56:10 +0300
committerIvan Kanakarakis <ivan.kanak@gmail.com>2020-05-12 13:43:31 +0300
commitd7a436518e11e5ee3791e7bb5c4169d321c844c7 (patch)
treef3e75e08a6541c5d93a61c72220582cb2966b86c
parentb8539198eb02149510a831e2c93c88ef8c438042 (diff)
downloadpysaml2-d7a436518e11e5ee3791e7bb5c4169d321c844c7.tar.gz
Remove cast to unicode
``` ************* Module saml2.saml src/saml2/saml.py:168:15: E0602: Undefined variable 'unicode' (undefined-variable) ``` There is no compatibility to python2 anymore. We can safely remove any such checks that tried to set the right types for the string object to catter for the differences in types between py2 and py3. Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
-rw-r--r--src/saml2/saml.py33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/saml2/saml.py b/src/saml2/saml.py
index 48edf415..e551bcb6 100644
--- a/src/saml2/saml.py
+++ b/src/saml2/saml.py
@@ -160,17 +160,16 @@ class AttributeValueBase(SamlBase):
def set_text(self, value, base64encode=False):
def _wrong_type_value(xsd, value):
- msg = _str('Type and value do not match: {xsd}:{type}:{value}')
+ msg = 'Type and value do not match: {xsd}:{type}:{value}'
msg = msg.format(xsd=xsd, type=type(value), value=value)
raise ValueError(msg)
# only work with six.string_types
- _str = unicode if six.PY2 else str
if isinstance(value, six.binary_type):
value = value.decode('utf-8')
type_to_xsd = {
- _str: 'string',
+ str: 'string',
int: 'integer',
float: 'float',
bool: 'boolean',
@@ -183,51 +182,51 @@ class AttributeValueBase(SamlBase):
# - a function to turn that type into a text-value
xsd_types_props = {
'string': {
- 'type': _str,
- 'to_type': _str,
- 'to_text': _str,
+ 'type': str,
+ 'to_type': str,
+ 'to_text': str,
},
'integer': {
'type': int,
'to_type': int,
- 'to_text': _str,
+ 'to_text': str,
},
'short': {
'type': int,
'to_type': int,
- 'to_text': _str,
+ 'to_text': str,
},
'int': {
'type': int,
'to_type': int,
- 'to_text': _str,
+ 'to_text': str,
},
'long': {
'type': int,
'to_type': int,
- 'to_text': _str,
+ 'to_text': str,
},
'float': {
'type': float,
'to_type': float,
- 'to_text': _str,
+ 'to_text': str,
},
'double': {
'type': float,
'to_type': float,
- 'to_text': _str,
+ 'to_text': str,
},
'boolean': {
'type': bool,
'to_type': lambda x: {
'true': True,
'false': False,
- }[_str(x).lower()],
- 'to_text': lambda x: _str(x).lower(),
+ }[str(x).lower()],
+ 'to_text': lambda x: str(x).lower(),
},
'base64Binary': {
- 'type': _str,
- 'to_type': _str,
+ 'type': str,
+ 'to_type': str,
'to_text': (
lambda x: base64.encodebytes(x.encode()) if base64encode else x
),
@@ -264,7 +263,7 @@ class AttributeValueBase(SamlBase):
to_text = xsd_type_props.get('to_text', str)
# cast to correct type before type-checking
- if type(value) is _str and valid_type is not _str:
+ if type(value) is str and valid_type is not str:
try:
value = to_type(value)
except (TypeError, ValueError, KeyError) as e: