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

Augie Fackler raf at durin42.com
Sat Oct 8 12:40:06 UTC 2016


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1475930143 14400
#      Sat Oct 08 08:35:43 2016 -0400
# Node ID 53708ce020c58f25079ef7b3802c71308843c0b4
# Parent  392dc40e200e6fdc3ee5172c949b81cc56163e62
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