From 64943e2f9df062427d91c3fe43fc4262d96b5460 Mon Sep 17 00:00:00 2001 From: Will Thames Date: Tue, 19 Mar 2019 00:40:28 +1000 Subject: [PATCH] Fix _hashable_policy for python3 (#53953) Convert policy to string before using `startswith(str)` Fixes #53932 --- lib/ansible/module_utils/ec2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/ec2.py b/lib/ansible/module_utils/ec2.py index fc88063b31d..d8d986dc903 100644 --- a/lib/ansible/module_utils/ec2.py +++ b/lib/ansible/module_utils/ec2.py @@ -561,10 +561,11 @@ def _hashable_policy(policy, policy_list): tupleified = tuple(tupleified) policy_list.append(tupleified) elif isinstance(policy, string_types) or isinstance(policy, binary_type): + policy = to_text(policy) # convert root account ARNs to just account IDs if policy.startswith('arn:aws:iam::') and policy.endswith(':root'): policy = policy.split(':')[4] - return [(to_text(policy))] + return [policy] elif isinstance(policy, dict): sorted_keys = list(policy.keys()) sorted_keys.sort()