D6050: revsetlang: use sysbytes() instead of blind encode()

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Sat Mar 2 16:26:37 EST 2019


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

REVISION SUMMARY
  Otherwise we will call str.encode() on Python 2, which is wrong.
  
  sysbytes() does encode('utf-8) on Python 3. But the source is
  guaranteed ASCII, so it shouldn't matter.
  
  With this change, `hg` now runs with `HGUNICODEPEDANTRY=1` set.
  However, several tests are failing.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revsetlang.py

CHANGE DETAILS

diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py
--- a/mercurial/revsetlang.py
+++ b/mercurial/revsetlang.py
@@ -62,8 +62,8 @@
 
 # default set of valid characters for the initial letter of symbols
 _syminitletters = set(pycompat.iterbytestr(
-    string.ascii_letters.encode('ascii') +
-    string.digits.encode('ascii') +
+    pycompat.sysbytes(string.ascii_letters) +
+    pycompat.sysbytes(string.digits) +
     '._@')) | set(map(pycompat.bytechr, pycompat.xrange(128, 256)))
 
 # default set of valid characters for non-initial letters of symbols



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


More information about the Mercurial-devel mailing list