Commit b30cb192 by Toshio Kuratomi Committed by James Cammarata

Wrap some filters so they return unicode.

The rules are -- if the filter returns str type and the str may contain
non-ascii characters then wrap it to convert to unicode type.  Not
needed if the function already returns unicode type or only returns
ascii characters

Conflicts:
	lib/ansible/runner/filter_plugins/core.py
parent a1a69d6d
...@@ -24,12 +24,16 @@ import pipes ...@@ -24,12 +24,16 @@ import pipes
import glob import glob
import re import re
import collections import collections
from functools import partial
import operator as py_operator import operator as py_operator
from ansible import errors
from ansible.utils import md5s, checksum_s
from distutils.version import LooseVersion, StrictVersion from distutils.version import LooseVersion, StrictVersion
from random import SystemRandom, shuffle from random import SystemRandom, shuffle
from jinja2.filters import environmentfilter from jinja2.filters import environmentfilter
from distutils.version import LooseVersion, StrictVersion
from ansible import errors
from ansible.utils.hashing import md5s, checksum_s
from ansible.utils.unicode import unicode_wrap
def to_nice_yaml(*a, **kw): def to_nice_yaml(*a, **kw):
...@@ -249,8 +253,8 @@ class FilterModule(object): ...@@ -249,8 +253,8 @@ class FilterModule(object):
def filters(self): def filters(self):
return { return {
# base 64 # base 64
'b64decode': base64.b64decode, 'b64decode': partial(unicode_wrap, base64.b64decode),
'b64encode': base64.b64encode, 'b64encode': partial(unicode_wrap, base64.b64encode),
# json # json
'to_json': to_json, 'to_json': to_json,
...@@ -263,11 +267,11 @@ class FilterModule(object): ...@@ -263,11 +267,11 @@ class FilterModule(object):
'from_yaml': yaml.safe_load, 'from_yaml': yaml.safe_load,
# path # path
'basename': os.path.basename, 'basename': unicode_wrap(os.path.basename),
'dirname': os.path.dirname, 'dirname': unicode_wrap(os.path.dirname),
'expanduser': os.path.expanduser, 'expanduser': unicode_wrap(os.path.expanduser),
'realpath': os.path.realpath, 'realpath': unicode_wrap(os.path.realpath),
'relpath': os.path.relpath, 'relpath': unicode_wrap(os.path.relpath),
# failure testing # failure testing
'failed' : failed, 'failed' : failed,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment