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.

Change History (1)

comment:1 by Aymeric Augustin, 12 years ago

Resolution: invalid
Status: newclosed

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 tell lazy to resolve it only as unicode (ie. six.text_type). Besides, lazy isn't documented, it's a private API.

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