changeset 42783:c8d3af9c7e65

perf: handle NameError for `pycompat.foo` when pycompat wasn't imported On old Mercurial versions, we won't have a pycompat variable defined, and then `pycompat.foo` will raise a NameError. Differential Revision: https://phab.mercurial-scm.org/D6743
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 19 Aug 2019 10:38:38 -0700
parents 1d9031b6cb7e
children 777a9df5a1ef
files contrib/perf.py
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/perf.py	Wed Aug 07 20:12:07 2019 +0200
+++ b/contrib/perf.py	Mon Aug 19 10:38:38 2019 -0700
@@ -132,7 +132,7 @@
         _maxint = sys.maxsize  # per py3 docs for replacing maxint
     else:
         _maxint = sys.maxint
-except (ImportError, AttributeError):
+except (NameError, ImportError, AttributeError):
     import inspect
     getargspec = inspect.getargspec
     _byteskwargs = identity
@@ -144,11 +144,11 @@
 try:
     # 4.7+
     queue = pycompat.queue.Queue
-except (AttributeError, ImportError):
+except (NameError, AttributeError, ImportError):
     # <4.7.
     try:
         queue = pycompat.queue
-    except (AttributeError, ImportError):
+    except (NameError, AttributeError, ImportError):
         queue = util.queue
 
 try: