Patchwork [1,of,6,py3,v2] extensions: use inspect module instead of func_code.co_argcount

login
register
mail settings
Submitter Augie Fackler
Date March 8, 2017, 10:51 p.m.
Message ID <6305f423089ed14fbf77.1489013475@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/19025/
State Superseded
Headers show

Comments

Augie Fackler - March 8, 2017, 10:51 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1488565641 18000
#      Fri Mar 03 13:27:21 2017 -0500
# Node ID 6305f423089ed14fbf77a0311b5ce472fd1e1d0d
# Parent  8dcc7582ec043d04d800a54a579f0f25ee7b44f4
extensions: use inspect module instead of func_code.co_argcount

Fixes the extsetup argspec check on Python 3.
Augie Fackler - March 8, 2017, 10:51 p.m.
Derp, misfire. I rebased but forgot to fix an issue here.
> On Mar 8, 2017, at 17:51, Augie Fackler <raf@durin42.com> wrote:
> 
> # HG changeset patch
> # User Augie Fackler <raf@durin42.com>
> # Date 1488565641 18000
> #      Fri Mar 03 13:27:21 2017 -0500
> # Node ID 6305f423089ed14fbf77a0311b5ce472fd1e1d0d
> # Parent  8dcc7582ec043d04d800a54a579f0f25ee7b44f4
> extensions: use inspect module instead of func_code.co_argcount
> 
> Fixes the extsetup argspec check on Python 3.
> 
> diff --git a/mercurial/extensions.py b/mercurial/extensions.py
> --- a/mercurial/extensions.py
> +++ b/mercurial/extensions.py
> @@ -8,6 +8,7 @@
> from __future__ import absolute_import
> 
> import imp
> +import inspect
> import os
> 
> from .i18n import (
> @@ -150,7 +151,7 @@ def _runextsetup(name, ui):
>         try:
>             extsetup(ui)
>         except TypeError:
> -            if extsetup.func_code.co_argcount != 0:
> +            if inspect.getargspec(extsetup).args:
>                 raise
>             extsetup() # old extsetup with no ui argument
> 
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -8,6 +8,7 @@ 
 from __future__ import absolute_import
 
 import imp
+import inspect
 import os
 
 from .i18n import (
@@ -150,7 +151,7 @@  def _runextsetup(name, ui):
         try:
             extsetup(ui)
         except TypeError:
-            if extsetup.func_code.co_argcount != 0:
+            if inspect.getargspec(extsetup).args:
                 raise
             extsetup() # old extsetup with no ui argument