Ok, so I've finally figured out what's going on here.
We don't pass through any environment variables to Mojo when executing this, and when using universal_newlines=True text is streamed using the encoding returned by locale.getpreferredencoding(False). Because we've not passed through (for example LANG) we end up with a preferred encoding of ANSI_X3.4-1968, which then fails on any unicode characters.
I was able to confirm the following fixes things (will discuss with a few folks whether this is the right approach and propose an MP):
cmd.extend(command)
try:
+ locale.setlocale(locale.LC_ALL, os.environ.get('LANG', 'en_US.UTF-8'))
return subprocess.check_output(cmd, universal_newlines=True)
except subprocess.CalledProcessError as cpe:
if command_timeout is not None:
Ok, so I've finally figured out what's going on here.
We don't pass through any environment variables to Mojo when executing this, and when using universal_ newlines= True text is streamed using the encoding returned by locale. getpreferredenc oding(False) . Because we've not passed through (for example LANG) we end up with a preferred encoding of ANSI_X3.4-1968, which then fails on any unicode characters.
I was able to confirm the following fixes things (will discuss with a few folks whether this is the right approach and propose an MP):
=== modified file 'mojo/juju/ status. py' juju/status. py 2021-02-05 12:12:08 +0000 juju/status. py 2021-04-15 09:47:31 +0000
--- old/mojo/
+++ new/mojo/
@@ -1,5 +1,6 @@
from __future__ import division, print_function
import datetime
+import locale
import logging
import os
import subprocess
@@ -41,6 +42,7 @@
cmd. extend( command) setlocale( locale. LC_ALL, os.environ. get('LANG' , 'en_US.UTF-8')) check_output( cmd, universal_ newlines= True) CalledProcessEr ror as cpe:
try:
+ locale.
return subprocess.
except subprocess.
if command_timeout is not None: