{{{
def view(request):
pass
v1 = functools.partial(view)
v2 = functools.partial(v1)
}}}
then set `v2` as the view for some url, then you'll get an attribute error
if you try reverse() on it :
AttributeError: 'functools.partial' object has no attribute '__module__'
{{{
File "/home/gstarck/work/public/python/django-
all/django/django/urls/base.py", line 91, in reverse
return force_text(iri_to_uri(resolver._reverse_with_prefix(view,
prefix, *args, **kwargs)))
File "/home/gstarck/work/public/python/django-
all/django/django/urls/resolvers.py", line 323, in _reverse_with_prefix
self._populate()
File "/home/gstarck/work/public/python/django-
all/django/django/urls/resolvers.py", line 183, in _populate
self._callback_strs.add(pattern.lookup_str)
File "/home/gstarck/work/public/python/django-
all/django/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/gstarck/work/public/python/django-
all/django/django/urls/resolvers.py", line 141, in lookup_str
return callback.__module__ + "." + callback.__class__.__name__
AttributeError: 'functools.partial' object has no attribute '__module__'
}}}
I have a patch / test case for this..
--
Ticket URL: <https://code.djangoproject.com/ticket/26039>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
I've initially raised my concern here:
https://github.com/django/django/pull/5578#discussion_r48514488
--
Ticket URL: <https://code.djangoproject.com/ticket/26039#comment:1>
* has_patch: 1 => 0
* stage: Unreviewed => Accepted
Comment:
Please check ''has patch'' when it is ready.
--
Ticket URL: <https://code.djangoproject.com/ticket/26039#comment:2>
* has_patch: 0 => 1
Comment:
I have a test case as well as a patch.. should I submit that as PR ?
--
Ticket URL: <https://code.djangoproject.com/ticket/26039#comment:3>
Comment (by charettes):
Please do, make sure the PR also refers to this ticket: `Fixed #26039 --
Unwrapped nested partials in URL reversal.`
--
Ticket URL: <https://code.djangoproject.com/ticket/26039#comment:4>
Comment (by timgraham):
[https://github.com/django/django/pull/5937 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/26039#comment:5>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"9f9921e89c5c559ff4324f8cf968007cefbf6442" 9f9921e]:
{{{
#!CommitTicketReference repository=""
revision="9f9921e89c5c559ff4324f8cf968007cefbf6442"
Fixed #26039 -- Unwrapped nested partials in URL reversal.
Prior to Python 3.5 nested partials need to be fully "unfolded"
to get the actual function.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26039#comment:6>