Skip to content

Commit

Permalink
Fix zip filter for Python3
Browse files Browse the repository at this point in the history
Using the now bundled six library.

Fixes ansible#28117
  • Loading branch information
andreaso authored and abadger committed Aug 15, 2017
1 parent aee3f12 commit c9cdc3a
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lib/ansible/plugins/filter/mathstuff.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

from ansible import errors
from ansible.module_utils import basic
from ansible.module_utils.six.moves import zip, zip_longest


def unique(a):
Expand Down Expand Up @@ -153,17 +154,10 @@ def filters(self):
'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

0 comments on commit c9cdc3a

Please sign in to comment.