[PATCH 2 of 2] extensions: pass ui arguement to extsetup if accepted
Martin Geisler
mg at lazybytes.net
Sat Aug 29 00:25:31 UTC 2009
Georg Brandl <g.brandl at gmx.net> writes:
> Dirkjan Ochtman schrieb:
>> On Wed, Aug 26, 2009 at 23:02, Simon Heimberg<simohe at besonet.ch> wrote:
>>> # HG changeset patch
>>> # User Simon Heimberg <simohe at besonet.ch>
>>> # Date 1250376084 -7200
>>> # Node ID 5f4e2711e3b2f1de44ce92616be43c5aa38e3e77
>>> # Parent 51ca46023b3844b11ee304555ac6f23b7581d67c
>>> extensions: pass ui arguement to extsetup if accepted
>>>
>>> diff -r 51ca46023b38 -r 5f4e2711e3b2 mercurial/extensions.py
>>> --- a/mercurial/extensions.py Son Aug 16 00:41:14 2009 +0200
>>> +++ b/mercurial/extensions.py Son Aug 16 00:41:24 2009 +0200
>>> @@ -117,7 +117,12 @@
>>> for name, mod in unloaded:
>>> extsetup = getattr(mod, 'extsetup', None)
>>> if extsetup:
>>> - extsetup()
>>> + try:
>>> + extsetup(ui)
>>> + except TypeError:
>>> + if extsetup.func_code.co_argcount != 0:
>>> + raise
>>> + extsetup() # old extsetup with no ui argument
>>
>> Why the try-except this way? Couldn't it just be
>>
>> if extsetup.func_code.co_argcount:
>> extsetup(ui)
>> else:
>> extsetup()
>
> Can't an extension be written in C?
I guess it can, do you mean that func_code.co_argcount wont be there in
that case? If so, do you know of a better way to handle this?
--
Martin Geisler
VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20090829/0d006e01/attachment.asc>
More information about the Mercurial-devel
mailing list