Opened 7 years ago

Closed 7 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: UI/UX:


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
    def inner(*args, **kwargs):
        bits = func(*args, **kwargs)
        return reverse(bits[0], None, *bits[1:3])
    return inner

Change History (3)

comment:1 Changed 7 years ago by Simon Law

Whoops, that wraps line should be:


comment:2 Changed 7 years ago by Adrian Holovaty

Triage Stage: UnreviewedAccepted

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

comment:3 Changed 7 years ago by Adrian Holovaty

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