a little more explicative error message?

Discussion in 'Python' started by Vito De Tullio, Jul 16, 2013.

  1. Hi

    I was writing a decorator and lost half an hour for a stupid bug in my code,
    but honestly the error the python interpreter returned to me doesn't
    helped...

    $ python3
    Python 3.3.0 (default, Feb 24 2013, 09:34:27)
    [GCC 4.7.2] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from functools import wraps
    >>> def dec(fun):

    .... @wraps
    .... def ret(*args, **kwargs):
    .... return fun(*args, **kwargs)
    .... return ret
    ....
    >>> @dec

    .... def fun(): pass
    ....
    >>> fun()

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    TypeError: update_wrapper() missing 1 required positional argument:
    'wrapper'
    >>>

    $


    Soo... at a first glance, no tricks... can you tell where is the error? :D



    As I said, the error is totally mine, I just forgot to pass the function as
    parameter to wraps. But... what is "update_wrapper()"? and "wrapper"? There
    is no useful traceback or something... just... this.

    Ok, the documentation clearly says:

    This is a convenience function to simplify applying partial() to
    update_wrapper().

    So, again, shame on me... I just read carefully the doc *after* 20 minutes
    trying everything else... still... I think should be useful if wraps()
    intercept this error saying something more explicit about the missing fun
    parameter...

    --
    ZeD
    Vito De Tullio, Jul 16, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael
    Replies:
    4
    Views:
    392
    Matt Hammond
    Jun 26, 2006
  2. ThaDoctor
    Replies:
    3
    Views:
    369
    Alan Woodland
    Sep 28, 2007
  3. Robert Klemme

    With a Ruby Yell: more, more more!

    Robert Klemme, Sep 28, 2005, in forum: Ruby
    Replies:
    5
    Views:
    195
    Jeff Wood
    Sep 29, 2005
  4. Daniel
    Replies:
    1
    Views:
    195
    Bart van Ingen Schenau
    Jul 9, 2013
  5. Terry Reedy
    Replies:
    0
    Views:
    71
    Terry Reedy
    Jul 16, 2013
Loading...

Share This Page