diff contrib/perf.py @ 36216:646002338365

py3: introduce and use pycompat.getargspec This is getfullargspec on py3, which means we can't use namedtuple named accessors for all fields (eg keywords from getargspec is varkw from getfullargspec, with the same meaning). Solves some warning issues on Python 3. I didn't clean up httpclient because that's vendored code I think we should probably discard, and I didn't touch the manpage generator for now either. Differential Revision: https://phab.mercurial-scm.org/D2251
author Augie Fackler <augie@google.com>
date Tue, 13 Feb 2018 23:00:01 -0700
parents 8b6dd3922f70
children df3f7f00a3fc
line wrap: on
line diff
--- a/contrib/perf.py	Tue Feb 13 23:37:58 2018 -0500
+++ b/contrib/perf.py	Tue Feb 13 23:00:01 2018 -0700
@@ -64,6 +64,12 @@
     from mercurial import scmutil # since 1.9 (or 8b252e826c68)
 except ImportError:
     pass
+try:
+    from mercurial import pycompat
+    getargspec = pycompat.getargspec  # added to module after 4.5
+except (ImportError, AttributeError):
+    import inspect
+    getargspec = inspect.getargspec
 
 # for "historical portability":
 # define util.safehasattr forcibly, because util.safehasattr has been
@@ -114,9 +120,8 @@
 if safehasattr(registrar, 'command'):
     command = registrar.command(cmdtable)
 elif safehasattr(cmdutil, 'command'):
-    import inspect
     command = cmdutil.command(cmdtable)
-    if 'norepo' not in inspect.getargspec(command)[0]:
+    if 'norepo' not in getargspec(command).args:
         # for "historical portability":
         # wrap original cmdutil.command, because "norepo" option has
         # been available since 3.1 (or 75a96326cecb)