#10491 closed Bug (fixed)
Passing a unicode-proxy to HttpResponse classes doesn't work
Reported by: | liangent | Owned by: | ajeeshvt |
---|---|---|---|
Component: | HTTP handling | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | liangent@…, bmispelon@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Passing a ugettext_lazy()
object as the argument to HttpResponseRedirect.__init__
doesn't work.
Attachments (1)
Change History (15)
Changed 15 years ago by
Attachment: | djtrans.zip added |
---|
comment:1 Changed 15 years ago by
Component: | Internationalization → HTTP handling |
---|---|
Description: | modified (diff) |
Triage Stage: | Unreviewed → Accepted |
comment:2 Changed 15 years ago by
Version: | → SVN |
---|
comment:3 Changed 15 years ago by
( #10498 )
and i wonder where to modify description of a ticket (or just opened by myself)
comment:4 Changed 13 years ago by
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:7 Changed 12 years ago by
Summary: | an unevaluated lazy object → Passing a unicode-proxy to HttpResponse classes doesn't work |
---|
comment:8 Changed 11 years ago by
Owner: | changed from nobody to ajeeshvt |
---|---|
Status: | new → assigned |
comment:9 Changed 11 years ago by
Status: | assigned → new |
---|
comment:10 Changed 11 years ago by
Cc: | bmispelon@… added |
---|---|
Has patch: | set |
Looking into this, it turns out that HttpResponse accepts lazy objects without issue (I haven't checked, but I suspect the force_bytes
call in HttpResponseBase.smart_bytes
is what makes it work).
However, the problem is still there for HttpResponseRedirect
.
I made a pull request that adds test for lazy object support in HttpResponse
and HttpResponseRedirect
and fix the behavior of HttpResponseRedirect
(just adding a force_text
call at the beginning of it).
comment:11 Changed 10 years ago by
I only hit upon this bug a couple of days ago. My use case was fairly common: automatic redirection to the login screen via the login_required decorator with LOGIN_URL setting being a lazily reversed url.
It used to work in Python 2.7 but fails in Python 3.3 inside urlparse() (that is assuming that HttpResponseRedirectBase has not changed lately).
Considering that Django allows lazy url-reverse for several versions now, I think fixing this is important.
comment:12 Changed 10 years ago by
Triage Stage: | Accepted → Ready for checkin |
---|
comment:13 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Please report only on bug per ticket. This is two bugs:
HttpResponse
classes doesn't convert it to ASCII (it assumes a str or str-proxy objects will be passed in).create()
on a reverse ForeignKey causes problems.I'm editing the description to describe the problem so that people don't have to work it out from the zip file and I'll open a new ticket for the second (entirely separate) problem. The original description was:
this shows
<django.utils.functional.__proxy__ object at 0x0110ED10>
, notxxx
i expectedthis bug also occurs when i'm trying to user.message_set.create(message=_(u'xxx'))