[jhbuild/pre-3-cleanup: 5/6] Set the Python 2 default encoding to utf-8



commit 5cb57f63479ebfae3f97ec354f4f08f1c1d2657a
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Sat Sep 21 21:52:19 2019 +0200

    Set the Python 2 default encoding to utf-8
    
    We are importing pygtk in some places, which does this.
    Do it at the start so it's the same on every run and in case
    we drop pygtk at some point.

 jhbuild/__init__.py | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/jhbuild/__init__.py b/jhbuild/__init__.py
index 4d12fb5b..8ea1f065 100644
--- a/jhbuild/__init__.py
+++ b/jhbuild/__init__.py
@@ -15,5 +15,13 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+# We used to import pygtk which sets things to utf-8 and masks ascii encoding errors.
+# It's usually what we want, and there are not many downsides, so replicate it here.
+import sys
+if sys.version_info[0] == 2:
+    import __builtin__
+    __builtin__.reload(sys)
+    sys.setdefaultencoding("utf-8")
+
 from jhbuild import monkeypatch
 del monkeypatch


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]