[issue1387] TypeError for wrapped commands with incorrect number of arguments

Brodie Rao mercurial-bugs at selenic.com
Thu Nov 13 09:59:20 CST 2008


New submission from Brodie Rao <dackze at gmail.com>:

With mainline, enabling an extension that wraps a command (like rebase and pull,
or mq and import), and using the command with an incorrect number of arguments
causes hg to incorrectly raise a TypeError:

For example, with rebase:

$ hg pull foo bar
...
  File "mercurial/dispatch.py", line 421, in _runcommand
    return checkargs()
  File "mercurial/dispatch.py", line 376, in checkargs
    return cmdfunc()
  File "mercurial/dispatch.py", line 359, in <lambda>
    d = lambda: func(ui, repo, *args, **cmdoptions)
  File "mercurial/extensions.py", line 99, in wrap
    return wrapper(origfn, *args, **kwargs)
  File "hgext/rebase.py", line 398, in pullrebase
    orig(ui, repo, *args, **opts)
TypeError: pull() takes at most 3 non-keyword arguments (4 given)

checkargs() in dispatch._runcommand() checks the length of the traceback when a
TypeError occurs. The length is longer when the command is wrapped, so it lets
the exception bubble up when it shouldn't.

----------
messages: 7900
nosy: brodie
priority: bug
status: unread
title: TypeError for wrapped commands with incorrect number of arguments

____________________________________________________
Mercurial issue tracker <mercurial-bugs at selenic.com>
<http://www.selenic.com/mercurial/bts/issue1387>
____________________________________________________



More information about the Mercurial-devel mailing list