[PATCH 2 of 3 v3] pycompat: when setting attrs, ensure we use sysstr

Augie Fackler raf at durin42.com
Sat Oct 8 11:10:08 EDT 2016


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1475930143 14400
#      Sat Oct 08 08:35:43 2016 -0400
# Node ID 1c7199563d7d8f400f907c63c133d7414ae1f684
# Parent  f8683a413385590d3083caba116034170bffd02e
pycompat: when setting attrs, ensure we use sysstr

The custom module importer was making these bytes, so when we poked
values into self.__dict__ we had bytes instead of unicode on py3 and
it didn't work.

diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -74,8 +74,10 @@ class _pycompatstub(object):
 
     def _registeraliases(self, origin, items):
         """Add items that will be populated at the first access"""
-        self._aliases.update((item.replace('_', '').lower(), (origin, item))
-                             for item in items)
+        items = map(sysstr, items)
+        self._aliases.update(
+            (item.replace(sysstr('_'), sysstr('')).lower(), (origin, item))
+            for item in items)
 
     def __getattr__(self, name):
         try:


More information about the Mercurial-devel mailing list