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

login
register
mail settings
Submitter Augie Fackler
Date Oct. 8, 2016, 3:10 p.m.
Message ID <1c7199563d7d8f400f90.1475939408@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/16931/
State Accepted
Headers show

Comments

Augie Fackler - Oct. 8, 2016, 3:10 p.m.
# HG changeset patch
# User Augie Fackler <augie@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.

Patch

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: