[Django] #25424: "AttributeError: '__proxy__' object has no attribute 'decode'" using reverse_lazy in test client

33 views
Skip to first unread message

Django

unread,
Sep 17, 2015, 8:34:17 PM9/17/15
to django-...@googlegroups.com
#25424: "AttributeError: '__proxy__' object has no attribute 'decode'" using
reverse_lazy in test client
-----------------------------------+--------------------
Reporter: SoftwareMaven | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------
This is basically the same as [https://code.djangoproject.com/ticket/18776
this bug], just starting from the test client. The relevant stack trace:


{{{
Traceback (most recent call last):
File "$SRC/tests/test_planner.py", line 49,
r = self.client.get(reverse_lazy('generator'))
File "$HOME/venvs/webapp/lib/python3.4/site-
packages/django/test/client.py", line 500, in get
**extra)
File "$HOME/venvs/webapp/lib/python3.4/site-
packages/django/test/client.py", line 303, in get
return self.generic('GET', path, secure=secure, **r)
File "$HOME/venvs/webapp/lib/python3.4/site-
packages/django/test/client.py", line 357, in generic
parsed = urlparse(path)
File
"$HOME/.pythonz/pythons/CPython-3.4.3/lib/python3.4/urllib/parse.py", line
292, in urlparse
url, scheme, _coerce_result = _coerce_args(url, scheme)
File
"$HOME/.pythonz/pythons/CPython-3.4.3/lib/python3.4/urllib/parse.py", line
112, in _coerce_args
return _decode_args(args) + (_encode_result,)
File
"$HOME/.pythonz/pythons/CPython-3.4.3/lib/python3.4/urllib/parse.py", line
96, in _decode_args
return tuple(x.decode(encoding, errors) if x else '' for x in args)
AttributeError: '__proxy__' object has no attribute 'decode'
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25424>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 17, 2015, 9:35:57 PM9/17/15
to django-...@googlegroups.com
#25424: "AttributeError: '__proxy__' object has no attribute 'decode'" using
reverse_lazy in test client
-------------------------------------+-------------------------------------
Reporter: SoftwareMaven | Owner:
| SoftwareMaven
Type: Bug | Status: assigned

Component: Testing framework | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by SoftwareMaven):

* status: new => assigned
* needs_better_patch: => 0
* owner: nobody => SoftwareMaven
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/25424#comment:1>

Django

unread,
Sep 17, 2015, 9:48:01 PM9/17/15
to django-...@googlegroups.com
#25424: "AttributeError: '__proxy__' object has no attribute 'decode'" using
reverse_lazy in test client
-------------------------------------+-------------------------------------
Reporter: SoftwareMaven | Owner:
| SoftwareMaven
Type: Bug | Status: assigned
Component: Testing framework | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by SoftwareMaven):

I've created a reproducer and a fix for this, based on the fix for 18776.
It is available at
https://github.com/SoftwareMaven/django/tree/ticket_25424.

This is my first foray into contributing to Django, so if there is
anything I missed in terms of process and what-not, please let me know.

--
Ticket URL: <https://code.djangoproject.com/ticket/25424#comment:2>

Django

unread,
Sep 18, 2015, 2:44:39 AM9/18/15
to django-...@googlegroups.com
#25424: "AttributeError: '__proxy__' object has no attribute 'decode'" using
reverse_lazy in test client
-------------------------------------+-------------------------------------
Reporter: SoftwareMaven | Owner:
| SoftwareMaven
Type: Bug | Status: assigned
Component: Testing framework | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by claudep):

* has_patch: 0 => 1
* stage: Unreviewed => Accepted


Comment:

Could you please transform your branch into a pull request ?

--
Ticket URL: <https://code.djangoproject.com/ticket/25424#comment:3>

Django

unread,
Sep 18, 2015, 1:46:16 PM9/18/15
to django-...@googlegroups.com
#25424: "AttributeError: '__proxy__' object has no attribute 'decode'" using
reverse_lazy in test client
-------------------------------------+-------------------------------------
Reporter: SoftwareMaven | Owner:
| SoftwareMaven
Type: Bug | Status: assigned
Component: Testing framework | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by SoftwareMaven):

Sure thing: https://github.com/django/django/pull/5313

--
Ticket URL: <https://code.djangoproject.com/ticket/25424#comment:4>

Django

unread,
Sep 19, 2015, 9:07:06 AM9/19/15
to django-...@googlegroups.com
#25424: "AttributeError: '__proxy__' object has no attribute 'decode'" using
reverse_lazy in test client
-------------------------------------+-------------------------------------
Reporter: SoftwareMaven | Owner:
| SoftwareMaven
Type: Bug | Status: closed

Component: Testing framework | Version: 1.8
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz <claude@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"1a09b3c398b42800de864023dad872d83b196181" 1a09b3c]:
{{{
#!CommitTicketReference repository=""
revision="1a09b3c398b42800de864023dad872d83b196181"
Fixed #25424 -- Use force_str for test client URLs.

urlparse() fails with an AttributeError ("'__proxy__' object has no
attribute 'decode'") if reverse_lazy is used to look up the URL
(this is exactly the same problem that caused ticket #18776). The
solution is to use force_str() on the path before handing it to
urlparse().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25424#comment:5>

Reply all
Reply to author
Forward
0 new messages