[anaconda][master] Make sure we always use "utf-8" as the default encoding (#1169019)

Vratislav Podzimek vpodzime at redhat.com
Wed Feb 18 17:09:04 UTC 2015


Our sitecustomize.py script doesn't work with live installations causing
various wierd issues with unicode objects and plain strings (in Python 2). This
way we can make sure we always use "utf-8" as the default encoding.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 anaconda                    |  7 +++++++
 pyanaconda/sitecustomize.py | 23 -----------------------
 2 files changed, 7 insertions(+), 23 deletions(-)
 delete mode 100644 pyanaconda/sitecustomize.py

diff --git a/anaconda b/anaconda
index 88091ab..623aef5 100755
--- a/anaconda
+++ b/anaconda
@@ -755,6 +755,13 @@ def cleanPStore():
     dir_tree_map("/sys/fs/pstore", os.unlink, files=True, dirs=False)
 
 if __name__ == "__main__":
+    # Force the "utf-8" encoding as the default (no idea why python doesn't have
+    # it as a default in 2015). The setdefaultencoding() function is removed
+    # from the sys module's namespace after site scripts are run so we need to
+    # reload the sys module.
+    reload(sys)
+    sys.setdefaultencoding('utf-8')
+
     # check if the CLI help is requested and return it at once,
     # without importing random stuff and spamming stdout
     if ("--help" in sys.argv) or ("-h" in sys.argv) or ("--version" in sys.argv):
diff --git a/pyanaconda/sitecustomize.py b/pyanaconda/sitecustomize.py
deleted file mode 100644
index a5e1a29..0000000
--- a/pyanaconda/sitecustomize.py
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# sitecustomize.py: The python site init code for the Red Hat Installer
-#
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
-# Red Hat, Inc.  All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-import sys
-# pylint: disable=no-member
-sys.setdefaultencoding('utf-8')
-- 
2.1.0



More information about the anaconda-patches mailing list