py3: use inspect.signature() instead of inspect.getargspec() on py3
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 11 Jul 2019 16:04:17 -0700
changeset 4746 724c67878d98
parent 4745 854637e3d2d0
child 4747 fa6aafa2857d
py3: use inspect.signature() instead of inspect.getargspec() on py3
hgext3rd/evolve/compat.py
--- a/hgext3rd/evolve/compat.py	Tue Jul 09 10:56:42 2019 -0700
+++ b/hgext3rd/evolve/compat.py	Thu Jul 11 16:04:17 2019 -0700
@@ -114,9 +114,14 @@
     args = [a, '', b, '', fn1, fn2]
 
     # hg < 4.6 compat 8b6dd3922f70
-    argspec = inspect.getargspec(mdiff.unidiff)
+    if util.safehasattr(inspect, 'signature'):
+        signature = inspect.signature(mdiff.unidiff)
+        needsbinary = 'binary' in signature.parameters
+    else:
+        argspec = inspect.getargspec(mdiff.unidiff)
+        needsbinary = 'binary' in argspec.args
 
-    if 'binary' in argspec.args:
+    if needsbinary:
         args.append(False)
 
     return mdiff.unidiff(*args)