On Wed, Feb 18, 2015 at 06:09:04PM +0100, Vratislav Podzimek wrote:
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(a)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')
I'm not sure about this. I find various references saying not to do
this, that it may break other things. I also came across this:
https://fedoraproject.org/wiki/Features/PythonEncodingUsesSystemLocale
But it doesn't look like the change was ever made since this happens on
f21:
python -c 'print u"\u03b1\u03b2\u03b3"' > foo.txt
Traceback (most recent call last):
File "<string>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2:
ordinal not in range(128)
My impression has always been that reload is for interactive use, and
even then generally doesn't work like you expect it to.
--
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)