#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)
by , 16 years ago
Attachment: | djtrans.zip added |
---|
comment:1 by , 16 years ago
Component: | Internationalization → HTTP handling |
---|---|
Description: | modified (diff) |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 16 years ago
Version: | → SVN |
---|
comment:3 by , 16 years ago
( #10498 )
and i wonder where to modify description of a ticket (or just opened by myself)
comment:4 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:7 by , 13 years ago
Summary: | an unevaluated lazy object → Passing a unicode-proxy to HttpResponse classes doesn't work |
---|
comment:8 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:9 by , 12 years ago
Status: | assigned → new |
---|
comment:10 by , 12 years ago
Cc: | 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 by , 11 years ago
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 by , 11 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:13 by , 11 years ago
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'))