D6043: UnicodeEncoding:change the default encoding of the whole script to be 'UTF-8'(issue6040)

akshjain.jain74 (Akshit Jain) phabricator at mercurial-scm.org
Sat Mar 2 09:16:31 EST 2019


akshjain.jain74 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6043

AFFECTED FILES
  hg
  hgext/pager.py
  hgext/phabricator.py
  mercurial/dispatch.py
  mercurial/scmutil.py
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -54,6 +54,9 @@
     stringutil,
 )
 
+reload(sys)
+sys.setdefaultencoding('utf8')
+
 base85 = policy.importmod(r'base85')
 osutil = policy.importmod(r'osutil')
 parsers = policy.importmod(r'parsers')
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -45,6 +45,11 @@
     vfs,
 )
 
+import sys
+reload(sys)
+sys.setdefaultencoding('utf8')
+
+
 from .utils import (
     procutil,
     stringutil,
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -18,6 +18,9 @@
 import time
 import traceback
 
+reload(sys)
+sys.setdefaultencoding('utf8')
+
 
 from .i18n import _
 
diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -41,6 +41,7 @@
 
 from __future__ import absolute_import
 
+import sys
 import contextlib
 import itertools
 import json
@@ -72,6 +73,9 @@
     procutil,
     stringutil,
 )
+reload(sys)
+sys.setdefaultencoding('utf8')
+
 
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
diff --git a/hgext/pager.py b/hgext/pager.py
--- a/hgext/pager.py
+++ b/hgext/pager.py
@@ -23,14 +23,20 @@
 '''
 from __future__ import absolute_import
 
+import sys
+
 from mercurial import (
     cmdutil,
     commands,
     dispatch,
     extensions,
     registrar,
     )
 
+reload(sys)
+sys.setdefaultencoding('utf8')
+
+
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
 # be specifying the version(s) of Mercurial they are tested with, or
diff --git a/hg b/hg
--- a/hg
+++ b/hg
@@ -14,7 +14,7 @@
 if os.environ.get('HGUNICODEPEDANTRY', False):
     try:
         reload(sys)
-        sys.setdefaultencoding("undefined")
+        sys.setdefaultencoding("utf8")
     except NameError:
         pass
 



To: akshjain.jain74, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list