Code

#19831 closed Bug (invalid)

django.utils.functional.lazy return __proxy__ object

Reported by: dydek 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.

Attachments (0)

Change History (1)

comment:1 Changed 14 months ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.