[PATCH 3 of 8] py3: handle sysstr conversion around get/set attr in contrib/perf
Matt Harbison
mharbison72 at gmail.com
Sat Sep 22 11:28:39 EDT 2018
# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1537575036 14400
# Fri Sep 21 20:10:36 2018 -0400
# Node ID c0c842de276702455060c3d5fd3a6aa80185cdc6
# Parent 0d1b3d5a92e159506c823be481cf9f57e45ec03d
py3: handle sysstr conversion around get/set attr in contrib/perf
diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -95,7 +95,7 @@ except (AttributeError, ImportError):
# available since 1.9.3 (or 94b200a11cf7)
_undefined = object()
def safehasattr(thing, attr):
- return getattr(thing, attr, _undefined) is not _undefined
+ return getattr(thing, pycompat.sysstr(attr), _undefined) is not _undefined
setattr(util, 'safehasattr', safehasattr)
# for "historical portability":
@@ -340,12 +340,12 @@ def safeattrsetter(obj, name, ignoremiss
raise error.Abort((b"missing attribute %s of %s might break assumption"
b" of performance measurement") % (name, obj))
- origvalue = getattr(obj, name)
+ origvalue = getattr(obj, pycompat.sysstr(name))
class attrutil(object):
def set(self, newvalue):
- setattr(obj, name, newvalue)
+ setattr(obj, pycompat.sysstr(name), newvalue)
def restore(self):
- setattr(obj, name, origvalue)
+ setattr(obj, pycompat.sysstr(name), origvalue)
return attrutil()
More information about the Mercurial-devel
mailing list