summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2018-03-25 08:19:36 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2018-04-05 12:29:55 (GMT)
commit401b65f8b34826f557f953a1ba384bec1b3d7f22 (patch)
tree70bdf03ad49c9da8e256712f570a61b2938b3bb0
parent239f39c0974de551c1898415a7faef1178a1ea19 (diff)
downloaddjango-mellon-401b65f8b34826f557f953a1ba384bec1b3d7f22.zip
django-mellon-401b65f8b34826f557f953a1ba384bec1b3d7f22.tar.gz
django-mellon-401b65f8b34826f557f953a1ba384bec1b3d7f22.tar.bz2
python3: adjust unicode usage
-rw-r--r--mellon/adapters.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/mellon/adapters.py b/mellon/adapters.py
index 7b136bd..fb79c6c 100644
--- a/mellon/adapters.py
+++ b/mellon/adapters.py
@@ -9,6 +9,7 @@ import requests.exceptions
from django.core.exceptions import PermissionDenied
from django.contrib import auth
from django.contrib.auth.models import Group
+from django.utils import six
from . import utils, app_settings, models
@@ -82,7 +83,7 @@ class DefaultAdapter(object):
realm = utils.get_setting(idp, 'REALM')
username_template = utils.get_setting(idp, 'USERNAME_TEMPLATE')
try:
- username = unicode(username_template).format(
+ username = six.u(username_template).format(
realm=realm, attributes=saml_attributes, idp=idp)[:30]
except ValueError:
self.logger.error(u'invalid username template %r', username_template)
@@ -112,7 +113,7 @@ class DefaultAdapter(object):
if (transient_federation_attribute
and saml_attributes.get(transient_federation_attribute)):
name_id = saml_attributes[transient_federation_attribute]
- if not isinstance(name_id, basestring):
+ if not isinstance(name_id, six.string_types):
if len(name_id) == 1:
name_id = name_id[0]
else:
@@ -160,7 +161,7 @@ class DefaultAdapter(object):
attribute_set = False
for field, tpl in attribute_mapping.items():
try:
- value = unicode(tpl).format(realm=realm, attributes=saml_attributes, idp=idp)
+ value = six.u(tpl).format(realm=realm, attributes=saml_attributes, idp=idp)
except ValueError:
self.logger.warning(u'invalid attribute mapping template %r', tpl)
except (AttributeError, KeyError, IndexError, ValueError) as e: