Fix locale_gen to compare native strings rather than mixing byte and text strings

Fixes #19426
This commit is contained in:
Toshio Kuratomi 2017-01-04 00:22:32 -08:00
commit e98c0a3009
6 changed files with 122 additions and 1 deletions

View file

@ -55,8 +55,9 @@ import os.path
from subprocess import Popen, PIPE, call
import re
from ansible.module_utils.basic import *
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils._text import to_native
LOCALE_NORMALIZATION = {
".utf8": ".UTF-8",
@ -99,6 +100,7 @@ def is_available(name, ubuntuMode):
def is_present(name):
"""Checks if the given locale is currently installed."""
output = Popen(["locale", "-a"], stdout=PIPE).communicate()[0]
output = to_native(output)
return any(fix_case(name) == fix_case(line) for line in output.splitlines())
def fix_case(name):