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

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Wed Aug 9 14:24:42 UTC 2017


durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Avoids some deprecation warnings when extension loading breaks.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/extensions.py

CHANGE DETAILS

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:



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


More information about the Mercurial-devel mailing list