call setlocale() and set LC_CTYPE to C.UTF-8 if it fails

This commit is contained in:
Michael Hudson-Doyle 2020-05-13 16:12:20 +12:00
parent acd6ee0032
commit fec0cfa094
1 changed files with 8 additions and 0 deletions

View File

@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import argparse
import locale
import logging
import os
import fcntl
@ -103,6 +104,13 @@ AUTO_ANSWERS_FILE = "/subiquity_config/answers.yaml"
def main():
# Python 3.7+ does more or less this by default, but we need to
# work with the Python 3.6 in bionic.
try:
locale.setlocale(locale.LC_ALL, "")
except locale.Error:
locale.setlocale(locale.LC_CTYPE, "C.UTF-8")
# Prefer utils from $SNAP, over system-wide
snap = os.environ.get('SNAP')
if snap: