Handles Python3 builtin changes

Some of the builtins (like map) have changed in Python3 in a way that
can lead to broken Python2 code.

bp python3
Change-Id: I632d857bd29a23db61538755f09da68f0cf7b723
changes/11/177411/5
David Stanek 8 years ago
parent c6e2beaa69
commit 853ca56771
  1. 2
      keystone/common/cache/_memcache_pool.py
  2. 1
      keystone/common/kvs/backends/memcached.py
  3. 5
      keystone/common/ldap/core.py
  4. 4
      keystone/contrib/federation/utils.py
  5. 5
      keystone/contrib/revoke/model.py
  6. 1
      keystone/tests/unit/filtering.py
  7. 7
      keystone/tests/unit/mapping_fixtures.py
  8. 1
      keystone/tests/unit/test_backend.py
  9. 1
      keystone/tests/unit/test_backend_endpoint_policy.py
  10. 1
      keystone/tests/unit/test_backend_ldap.py
  11. 1
      keystone/tests/unit/test_backend_sql.py
  12. 2
      keystone/tests/unit/test_backend_templated.py
  13. 1
      keystone/tests/unit/test_cache_backend_mongo.py
  14. 1
      keystone/tests/unit/test_cli.py
  15. 1
      keystone/tests/unit/test_ldap_livetest.py
  16. 1
      keystone/tests/unit/test_revoke.py
  17. 1
      keystone/tests/unit/test_v2_keystoneclient.py
  18. 1
      keystone/tests/unit/test_v3_assignment.py
  19. 3
      keystone/tests/unit/test_v3_auth.py
  20. 1
      keystone/tests/unit/test_v3_controller.py
  21. 4
      keystone/tests/unit/test_v3_federation.py
  22. 1
      keystone/tests/unit/test_v3_filters.py
  23. 1
      keystone/tests/unit/token/test_token_model.py
  24. 11
      keystone/token/providers/fernet/token_formatters.py
  25. 1
      keystone/trust/backends/sql.py
  26. 1
      keystone/trust/core.py

@ -27,7 +27,7 @@ import time
import memcache
from oslo_log import log
from six.moves import queue
from six.moves import queue, zip
from keystone import exception
from keystone.i18n import _

@ -23,6 +23,7 @@ from dogpile.cache import api
from dogpile.cache.backends import memcached
from oslo_config import cfg
from oslo_log import log
from six.moves import range
from keystone.common.cache.backends import memcache_pool
from keystone import exception

@ -24,6 +24,7 @@ import ldap.filter
import ldappool
from oslo_log import log
import six
from six.moves import map, zip
from keystone import exception
from keystone.i18n import _
@ -939,7 +940,7 @@ class KeystoneLDAPHandler(LDAPHandler):
if attrlist is None:
attrlist_utf8 = None
else:
attrlist_utf8 = map(utf8_encode, attrlist)
attrlist_utf8 = list(map(utf8_encode, attrlist))
ldap_result = self.conn.search_s(base_utf8, scope,
filterstr_utf8,
attrlist_utf8, attrsonly)
@ -990,7 +991,7 @@ class KeystoneLDAPHandler(LDAPHandler):
attrlist_utf8 = None
else:
attrlist = [attr for attr in attrlist if attr is not None]
attrlist_utf8 = map(utf8_encode, attrlist)
attrlist_utf8 = list(map(utf8_encode, attrlist))
msgid = self.conn.search_ext(base_utf8,
scope,
filterstr_utf8,

@ -509,8 +509,8 @@ class RuleProcessor(object):
"""
def extract_groups(groups_by_domain):
for groups in groups_by_domain.values():
for group in {g['name']: g for g in groups}.values():
for groups in list(groups_by_domain.values()):
for group in list({g['name']: g for g in groups}.values()):
yield group
def normalize_user(user):

@ -11,6 +11,7 @@
# under the License.
from oslo_utils import timeutils
from six.moves import map
# The set of attributes common between the RevokeEvent
@ -111,7 +112,7 @@ class RevokeEvent(object):
def attr_keys(event):
return map(event.key_for_name, _EVENT_NAMES)
return list(map(event.key_for_name, _EVENT_NAMES))
class RevokeTree(object):
@ -176,7 +177,7 @@ class RevokeTree(object):
del parent[key]
def add_events(self, revoke_events):
return map(self.add_event, revoke_events or [])
return list(map(self.add_event, revoke_events or []))
def is_revoked(self, token_data):
"""Check if a token matches the revocation event

@ -15,6 +15,7 @@
import uuid
from oslo_config import cfg
from six.moves import range
CONF = cfg.CONF

@ -12,6 +12,9 @@
"""Fixtures for Federation Mapping."""
from six.moves import range, zip
EMPLOYEE_GROUP_ID = "0cd5e9"
CONTRACTOR_GROUP_ID = "85a868"
TESTER_GROUP_ID = "123"
@ -989,8 +992,8 @@ MALFORMED_TESTER_ASSERTION = {
'LastName': 'Account',
'orgPersonType': 'Tester',
'object': object(),
'dictionary': dict(zip('teststring', xrange(10))),
'tuple': tuple(xrange(5))
'dictionary': dict(zip('teststring', range(10))),
'tuple': tuple(range(5))
}
DEVELOPER_ASSERTION = {

@ -22,6 +22,7 @@ import mock
from oslo_config import cfg
from oslo_utils import timeutils
import six
from six.moves import range
from testtools import matchers
from keystone.catalog import core

@ -14,6 +14,7 @@
import uuid
from six.moves import range
from testtools import matchers
from keystone import exception

@ -20,6 +20,7 @@ import uuid
import ldap
import mock
from oslo_config import cfg
from six.moves import range
from testtools import matchers
from keystone.common import cache

@ -20,6 +20,7 @@ import mock
from oslo_config import cfg
from oslo_db import exception as db_exception
from oslo_db import options
from six.moves import range
import sqlalchemy
from sqlalchemy import exc
from testtools import matchers

@ -15,6 +15,8 @@
import os
import uuid
from six.moves import zip
from keystone.tests import unit as tests
from keystone.tests.unit import default_fixtures
from keystone.tests.unit.ksfixtures import database

@ -20,6 +20,7 @@ import uuid
from dogpile.cache import api
from dogpile.cache import region as dp_region
import six
from six.moves import range
from keystone.common.cache.backends import mongo
from keystone import exception

@ -17,6 +17,7 @@ import uuid
import mock
from oslo_config import cfg
from six.moves import range
from keystone import cli
from keystone.common import dependency

@ -18,6 +18,7 @@ import uuid
import ldap
import ldap.modlist
from oslo_config import cfg
from six.moves import range
from keystone import exception
from keystone.identity.backends import ldap as identity_ldap

@ -16,6 +16,7 @@ import uuid
import mock
from oslo_utils import timeutils
from six.moves import range
from testtools import matchers
from keystone.contrib import revoke

@ -21,6 +21,7 @@ import mock
from oslo_config import cfg
from oslo_serialization import jsonutils
from oslo_utils import timeutils
from six.moves import range
import webob
from keystone.tests import unit as tests

@ -15,6 +15,7 @@ import uuid
from oslo_config import cfg
import six
from six.moves import range
from keystone.common import controller
from keystone import exception

@ -23,6 +23,7 @@ import mock
from oslo_config import cfg
from oslo_utils import timeutils
import six
from six.moves import range
from testtools import matchers
from testtools import testcase
@ -2921,7 +2922,7 @@ class TestTrustChain(test_v3.RestfulTestCase):
# Create trust chain
self.user_chain = list()
self.trust_chain = list()
for _ in xrange(3):
for _ in range(3):
user_ref = self.new_user_ref(domain_id=self.domain_id)
user = self.identity_api.create_user(user_ref)
user['password'] = user_ref['password']

@ -15,6 +15,7 @@
import uuid
import six
from six.moves import range
from testtools import matchers
from keystone.common import controller

@ -25,7 +25,7 @@ from oslotest import mockpatch
import saml2
from saml2 import saml
from saml2 import sigver
from six.moves import urllib
from six.moves import range, urllib, zip
import xmldsig
from keystone.auth import controllers as auth_controllers
@ -2155,7 +2155,7 @@ class FederatedTokenTests(FederationTests, FederatedSetupMixin):
context = {
'environment': {
'malformed_object': object(),
'another_bad_idea': tuple(xrange(10)),
'another_bad_idea': tuple(range(10)),
'yet_another_bad_param': dict(zip(uuid.uuid4().hex,
range(32)))
}

@ -17,6 +17,7 @@ import uuid
from oslo_config import cfg
from oslo_serialization import jsonutils
from six.moves import range
from keystone.tests.unit import filtering
from keystone.tests.unit.ksfixtures import temporaryfile

@ -15,6 +15,7 @@ import uuid
from oslo_config import cfg
from oslo_utils import timeutils
from six.moves import range
from keystone import exception
from keystone.models import token_model

@ -21,7 +21,7 @@ from oslo_config import cfg
from oslo_log import log
from oslo_utils import timeutils
import six
from six.moves import urllib
from six.moves import map, urllib
from keystone.auth import plugins as auth_plugins
from keystone import exception
@ -508,12 +508,13 @@ class FederatedPayload(BasePayload):
b_user_id = cls.attempt_convert_uuid_hex_to_bytes(user_id)
methods = auth_plugins.convert_method_list_to_integer(methods)
b_group_ids = map(pack_group_ids, federated_info['group_ids'])
b_group_ids = list(map(pack_group_ids, federated_info['group_ids']))
b_idp_id = cls.attempt_convert_uuid_hex_to_bytes(
federated_info['idp_id'])
protocol_id = federated_info['protocol_id']
expires_at_int = cls._convert_time_string_to_int(expires_at)
b_audit_ids = map(provider.random_urlsafe_str_to_bytes, audit_ids)
b_audit_ids = list(map(provider.random_urlsafe_str_to_bytes,
audit_ids))
return (b_user_id, methods, b_group_ids, b_idp_id, protocol_id,
expires_at_int, b_audit_ids)
@ -535,11 +536,11 @@ class FederatedPayload(BasePayload):
user_id = cls.attempt_convert_uuid_bytes_to_hex(payload[0])
methods = auth_plugins.convert_integer_to_method_list(payload[1])
group_ids = map(unpack_group_ids, payload[2])
group_ids = list(map(unpack_group_ids, payload[2]))
idp_id = cls.attempt_convert_uuid_bytes_to_hex(payload[3])
protocol_id = payload[4]
expires_at_str = cls._convert_int_to_time_string(payload[5])
audit_ids = map(provider.base64_encode, payload[6])
audit_ids = list(map(provider.base64_encode, payload[6]))
federated_info = dict(group_ids=group_ids, idp_id=idp_id,
protocol_id=protocol_id)
return (user_id, methods, expires_at_str, audit_ids, federated_info)

@ -16,6 +16,7 @@ import time
from oslo_log import log
from oslo_utils import timeutils
from six.moves import range
from keystone.common import sql
from keystone import exception

@ -19,6 +19,7 @@ import abc
from oslo_config import cfg
from oslo_log import log
import six
from six.moves import zip
from keystone.common import dependency
from keystone.common import manager

Loading…
Cancel
Save