#24097 closed Bug (fixed)
Python3 AttributeError with redirect_to_login and lazy LOGIN_URL
Reported by: | Peter Schmidt | Owned by: | nobody |
---|---|---|---|
Component: | contrib.auth | Version: | 1.7 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
See discussion on #18776 to decide whether to keep patching symptoms or fix the root cause.
Ran into the same AttributeError: '__proxy__' object has no attribute 'decode'
.
Please see attached test_redirect_to_login.diff
or https://github.com/mathspace/django/compare/error-lazylogin-master which passes under Python 2.7 but throws the AttributeError under Python 3.4
One workaround is to explicitly pass the string form of the variable, i.e.
redirect_to_login(next=..., login_url=str(settings.LOGIN_URL))
Attachments (2)
Change History (12)
by , 10 years ago
Attachment: | test_redirect_to_login.diff added |
---|
comment:1 by , 10 years ago
Description: | modified (diff) |
---|
comment:2 by , 10 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
by , 10 years ago
Attachment: | 24097_lazy.diff added |
---|
comment:3 by , 10 years ago
Re: 24097_lazy.diff
please see commit comments on https://github.com/mathspace/django/compare/error-lazylogin-master
comment:4 by , 10 years ago
Has patch: | set |
---|
comment:5 by , 10 years ago
Version: | master → 1.7 |
---|
This doesn't appear to be a regression in master as 1.7 and 1.6 are also affected (seems like a crashing issue worth backporting though).
comment:6 by , 10 years ago
I would be tempted to solve the issue in django.shortcuts.resolve_url
by expanding the URL to a string when it's a lazy instance. Thoughts?
comment:8 by , 10 years ago
Replying to claudep:
Alternate PR: https://github.com/django/django/pull/3874
+1 here. This also cleans up the quick fix for #18776 which is good.
My attempt at a patch did feel like I was fighting the Zen of Python by getting too involved with str vs bytes.
Thanks to Oktay Sancak for writing the original failing test (albeit under Python2) and Alvin Savoy for supporting contributing back to the community.
comment:9 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Could you elaborate about your
fix the root cause
idea?