From c9cdc3a259973bfcc425260520e34fa59b6f8acb Mon Sep 17 00:00:00 2001 From: Andreas Olsson Date: Mon, 14 Aug 2017 14:49:43 +0200 Subject: [PATCH] Fix zip filter for Python3 Using the now bundled six library. Fixes #28117 --- lib/ansible/plugins/filter/mathstuff.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/ansible/plugins/filter/mathstuff.py b/lib/ansible/plugins/filter/mathstuff.py index 6e3cc94fe2..e498abc54e 100644 --- a/lib/ansible/plugins/filter/mathstuff.py +++ b/lib/ansible/plugins/filter/mathstuff.py @@ -26,6 +26,7 @@ import math from ansible import errors from ansible.module_utils import basic +from ansible.module_utils.six.moves import zip, zip_longest def unique(a): @@ -153,17 +154,10 @@ class FilterModule(object): 'human_readable': human_readable, 'human_to_bytes': human_to_bytes, + # zip + 'zip': zip, + 'zip_longest': zip_longest, + } - # py2 vs py3, reverse when py3 is predominant version - try: - filters['zip'] = itertools.izip - filters['zip_longest'] = itertools.izip_longest - except AttributeError: - try: - filters['zip'] = itertools.zip - filters['zip_longest'] = itertools.zip_longest - except: - pass - return filters