Opened 12 years ago
Closed 12 years ago
#19831 closed Bug (invalid)
django.utils.functional.lazy return __proxy__ object
Reported by: | Michał Dydecki | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | 1.5-rc-1 |
Severity: | Normal | Keywords: | lazy |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
There is a problem with lazy wrapper used in fe. django.core.context_processors in csrf function.
Let me show You an example:
In [23]: def test():
return "test string"
In [24]: t = lazy(test, six.text_type)
In [25]: print t()
<django.utils.functional.proxy object at 0x26b3c90>
t() should return proper value from function test.
This situation cause a problem with setting csrftoken cookie. It's only possible when You are using function
_get_val without lazy wrapper.
Note:
See TracTickets
for help on using tickets.
Assuming your example is under Python 2, and
unicode_literals
isn't in effect, you're seeing the expected behavior.test()
returns a bytestring and you telllazy
to resolve it only asunicode
(ie.six.text_type
). Besides,lazy
isn't documented, it's a private API.