D4743: encoding: remove unnecessary lambdas from _encodingfixers

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Wed Sep 26 07:49:47 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG9e8fcd2e78c1: encoding: remove unnecessary lambdas from _encodingfixers (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4743?vs=11360&id=11371

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

AFFECTED FILES
  mercurial/encoding.py

CHANGE DETAILS

diff --git a/mercurial/encoding.py b/mercurial/encoding.py
--- a/mercurial/encoding.py
+++ b/mercurial/encoding.py
@@ -68,21 +68,21 @@
     environ = dict((k.encode(u'utf-8'), v.encode(u'utf-8'))
                    for k, v in os.environ.items())  # re-exports
 
-_encodingfixers = {
-    '646': lambda: 'ascii',
-    'ANSI_X3.4-1968': lambda: 'ascii',
+_encodingrewrites = {
+    '646': 'ascii',
+    'ANSI_X3.4-1968': 'ascii',
 }
 # cp65001 is a Windows variant of utf-8, which isn't supported on Python 2.
 # No idea if it should be rewritten to the canonical name 'utf-8' on Python 3.
 # https://bugs.python.org/issue13216
 if pycompat.iswindows and not pycompat.ispy3:
-    _encodingfixers['cp65001'] = lambda: 'utf-8'
+    _encodingrewrites['cp65001'] = 'utf-8'
 
 try:
     encoding = environ.get("HGENCODING")
     if not encoding:
         encoding = locale.getpreferredencoding().encode('ascii') or 'ascii'
-        encoding = _encodingfixers.get(encoding, lambda: encoding)()
+        encoding = _encodingrewrites.get(encoding, encoding)
 except locale.Error:
     encoding = 'ascii'
 encodingmode = environ.get("HGENCODINGMODE", "strict")



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list