Patchwork [05,of,10] py3: make adefaults keys str to be compatible with getattr

login
register
mail settings
Submitter Pulkit Goyal
Date May 4, 2017, 10:46 p.m.
Message ID <48c75bcbe8a3a4cc7e49.1493938010@pulkit-goyal>
Download mbox | patch
Permalink /patch/20444/
State Accepted
Headers show

Comments

Pulkit Goyal - May 4, 2017, 10:46 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1493838893 -19800
#      Thu May 04 00:44:53 2017 +0530
# Node ID 48c75bcbe8a3a4cc7e491c4c60707fa80faf9a9d
# Parent  2dac09b43b78e59b4035bd8e45374fa8814456af
py3: make adefaults keys str to be compatible with getattr

getattr passes a str value of the attribute to be looked and keys in adefaults
dict are bytes which resulted in AttributeError. This patch abuses r'' to
make the keys str.

Patch

diff -r 2dac09b43b78 -r 48c75bcbe8a3 mercurial/dispatch.py
--- a/mercurial/dispatch.py	Thu May 04 00:24:21 2017 +0530
+++ b/mercurial/dispatch.py	Thu May 04 00:44:53 2017 +0530
@@ -479,7 +479,8 @@ 
         return aliasargs(self.fn, args)
 
     def __getattr__(self, name):
-        adefaults = {'norepo': True, 'optionalrepo': False, 'inferrepo': False}
+        adefaults = {r'norepo': True,
+                        r'optionalrepo': False, r'inferrepo': False}
         if name not in adefaults:
             raise AttributeError(name)
         if self.badalias or util.safehasattr(self, 'shell'):