Mercurial > public > mercurial-scm > hg
comparison mercurial/extensions.py @ 31263:d79761fe697f
extensions: use inspect module instead of func_code.co_argcount
Fixes the extsetup argspec check on Python 3.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Fri, 03 Mar 2017 13:27:21 -0500 |
parents | 2912b06905dc |
children | 063d7957fa12 |
comparison
equal
deleted
inserted
replaced
31262:1871a1ee64ed | 31263:d79761fe697f |
---|---|
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | 9 |
10 import imp | 10 import imp |
11 import inspect | |
11 import os | 12 import os |
12 | 13 |
13 from .i18n import ( | 14 from .i18n import ( |
14 _, | 15 _, |
15 gettext, | 16 gettext, |
148 extsetup = getattr(_extensions[name], 'extsetup', None) | 149 extsetup = getattr(_extensions[name], 'extsetup', None) |
149 if extsetup: | 150 if extsetup: |
150 try: | 151 try: |
151 extsetup(ui) | 152 extsetup(ui) |
152 except TypeError: | 153 except TypeError: |
153 if extsetup.func_code.co_argcount != 0: | 154 if inspect.getargspec(extsetup).args: |
154 raise | 155 raise |
155 extsetup() # old extsetup with no ui argument | 156 extsetup() # old extsetup with no ui argument |
156 | 157 |
157 def loadall(ui): | 158 def loadall(ui): |
158 result = ui.configitems("extensions") | 159 result = ui.configitems("extensions") |