diff -r 1871a1ee64ed -r d79761fe697f mercurial/extensions.py --- a/mercurial/extensions.py Tue Mar 07 18:29:58 2017 -0800 +++ b/mercurial/extensions.py Fri Mar 03 13:27:21 2017 -0500 @@ -8,6 +8,7 @@ from __future__ import absolute_import import imp +import inspect import os from .i18n import ( @@ -150,7 +151,7 @@ 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