From: David Shea dshea@redhat.com
Replacing stdout in the middle of the program is about as good of an idea as it looks like, turns out. While it seems to work fine in text mode, prints to stdout will just silently disappear after setup_locale is called by the GUI welcome spoke.
Most of the time replacing the standard streams is not necessary. Anaconda will have either already started in a UTF-8 locale, or the first, early call to setup_locale in /usr/sbin/anaconda will switch to a UTF-8 locale. So for the cases where we do not need to replace the streams, don't. --- pyanaconda/localization.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/pyanaconda/localization.py b/pyanaconda/localization.py index 43a2ed1..f86180a 100644 --- a/pyanaconda/localization.py +++ b/pyanaconda/localization.py @@ -282,9 +282,13 @@ def setup_locale(locale, lang=None, text_mode=False): # characters and sys.stdout doesn't know what to do with them. So, when changing # the locale, create new objects for the standard streams so they are created with # the new locale's encoding. - sys.stdin = io.TextIOWrapper(sys.stdin.detach()) - sys.stdout = io.TextIOWrapper(sys.stdout.detach()) - sys.stderr = io.TextIOWrapper(sys.stderr.detach()) + + # Replacing stdout is about as stable as it looks, and it seems to break when done + # after the GUI is started. Only make the switch if the encoding actually changed. + if locale_mod.getpreferredencoding() != sys.stdout.encoding: + sys.stdin = io.TextIOWrapper(sys.stdin.detach()) + sys.stdout = io.TextIOWrapper(sys.stdout.detach()) + sys.stderr = io.TextIOWrapper(sys.stderr.detach())
def get_english_name(locale): """