Opened 14 years ago

Closed 14 years ago

#15604 closed (fixed)

django.db.models.permalink eats docstring

Reported by: Simon Law Owned by: nobody
Component: Core (Other) Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The django.db.models.permalink decorator eats docstrings, along with the other metadata that it is wrapping. That's because it's not using functools.wraps on its inner function.

It should be defined like this:

from django.utils.decorators import wraps

def permalink(func):
    from django.core.urlresolvers import reverse
    @wraps
    def inner(*args, **kwargs):
        bits = func(*args, **kwargs)
        return reverse(bits[0], None, *bits[1:3])
    return inner

Change History (3)

comment:1 by Simon Law, 14 years ago

Whoops, that wraps line should be:

@wraps(func)

comment:2 by Adrian Holovaty, 14 years ago

Triage Stage: UnreviewedAccepted

Good improvement. I'll add this along with some tests.

comment:3 by Adrian Holovaty, 14 years ago

Resolution: fixed
Status: newclosed

In [15798]:

Fixed #15604 -- Changed django.db.models.permalink to use wraps() so that it doesn't eat the docstring. Thanks for the report, sfllaw. Also added tests.

Note: See TracTickets for help on using tickets.
Back to Top