On (04/08/15 15:20), Christian Heimes wrote: >On 2015-08-04 15:13, Lukas Slebodnik wrote: >> ehlo, >> >> attached patch fixes ticket #2699 >> >> On other places we do not require to return list by dict.keys(). >> There were patterns: >> something in a_dictionary.keys() >> ", ".join(a_dictionary.keys())) > >You don't have to call the keys() method at all. list(a_dict) gives you >a list of keys on all versions of Python. If you need a sorted list, you >can use sorted(a_dict). These days the keys() method is considered bad >style. > Updated patch is attached.
LS
>From 7c4d7f50b48479c9842f6462dcb550c03ed4d8ef Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <lsleb...@redhat.com> Date: Tue, 4 Aug 2015 15:03:44 +0200 Subject: [PATCH] SSSDConfig: Return correct types in python3 In Python 3, dict.keys() returns a view rather than a list. Since dict keys aren't in any particular order, indexing them doesn't make sense. Resolves: https://fedorahosted.org/sssd/ticket/2699 --- src/config/SSSDConfig/__init__.py.in | 4 ++-- src/config/SSSDConfigTest.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/config/SSSDConfig/__init__.py.in b/src/config/SSSDConfig/__init__.py.in index 7d361026c09ce8fd8d6a69f6bb3f3817bc3d68ba..49de53eaa9aadda9d3ceb0eea6fee647b4f667a2 100644 --- a/src/config/SSSDConfig/__init__.py.in +++ b/src/config/SSSDConfig/__init__.py.in @@ -1498,7 +1498,7 @@ class SSSDConfig(SSSDChangeConf): if srv not in configured_services: del service_dict[srv] - active_services = service_dict.keys() + active_services = list(service_dict) else: active_services = [] @@ -1781,7 +1781,7 @@ class SSSDConfig(SSSDChangeConf): if dom not in configured_domains: del domain_dict[dom] - active_domains = domain_dict.keys() + active_domains = list(domain_dict) else: active_domains = [] diff --git a/src/config/SSSDConfigTest.py b/src/config/SSSDConfigTest.py index 1d6107ceac1bde7acbfd2682cc144a4ef0881311..67289e012b863501cfae7761794633193e6a51c0 100755 --- a/src/config/SSSDConfigTest.py +++ b/src/config/SSSDConfigTest.py @@ -1299,6 +1299,7 @@ class SSSDConfigTestSSSDConfig(unittest.TestCase): 'nss', 'pam'] active_services = sssdconfig.list_active_services() + self.assertTrue(isinstance(active_services, list)) for service in control_list: self.assertTrue(service in active_services, @@ -1521,6 +1522,7 @@ class SSSDConfigTestSSSDConfig(unittest.TestCase): 'IPA', 'LOCAL'] active_domains = sssdconfig.list_active_domains() + self.assertTrue(isinstance(active_domains, list)) for domain in control_list: self.assertTrue(domain in active_domains, -- 2.5.0
_______________________________________________ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/sssd-devel