Patchwork D295: extensions: attempt to use non-deprecated inspect method

login
register
mail settings
Submitter phabricator
Date Aug. 9, 2017, 3:25 p.m.
Message ID <12787c9c8caf3782ba90bcdd2c8a7e33@localhost.localdomain>
Download mbox | patch
Permalink /patch/22805/
State Not Applicable
Headers show

Comments

phabricator - Aug. 9, 2017, 3:25 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG62fbe95075d3: extensions: attempt to use non-deprecated inspect method (authored by durin42).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D295?vs=678&id=690

REVISION DETAIL
  https://phab.mercurial-scm.org/D295

AFFECTED FILES
  mercurial/extensions.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -186,7 +186,11 @@ 
             try:
                 extsetup(ui)
             except TypeError:
-                if inspect.getargspec(extsetup).args:
+                # Try to use getfullargspec (Python 3) first, and fall
+                # back to getargspec only if it doesn't exist so as to
+                # avoid warnings.
+                if getattr(inspect, 'getfullargspec',
+                           getattr(inspect, 'getargspec'))(extsetup).args:
                     raise
                 extsetup() # old extsetup with no ui argument
         except Exception as inst: