changeset 4746:724c67878d98

py3: use inspect.signature() instead of inspect.getargspec() on py3
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 11 Jul 2019 16:04:17 -0700
parents 854637e3d2d0
children fa6aafa2857d
files hgext3rd/evolve/compat.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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)