[Django] #23782: Lazy objects don't support __contains__

6 views
Skip to first unread message

Django

unread,
Nov 9, 2014, 10:03:58 AM11/9/14
to django-...@googlegroups.com
#23782: Lazy objects don't support __contains__
-------------------------------+--------------------
Reporter: Kronuz | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
While trying to use SimpleLazyObject to check if something is contained in
an object, the following throws an exception (`AttributeError: 'int'
object has no attribute 'lower'`) when the `not in` fallback to the
sequence iteration protocol: `'Content-Language' not in
SimpleLazyObject(lambda: HttpResponseRedirect('/'))`

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

Django

unread,
Nov 15, 2014, 5:49:49 AM11/15/14
to django-...@googlegroups.com
#23782: Lazy objects don't support __contains__
-------------------------------+--------------------------------------

Reporter: Kronuz | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.7
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 mrbox):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

I see this operator in SimpleLazyObject here:
https://github.com/django/django/blob/1.7/django/utils/functional.py#L330
Also added a test to check if it behaves as expected:
https://github.com/django/django/pull/3514

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

Django

unread,
Nov 15, 2014, 6:04:19 AM11/15/14
to django-...@googlegroups.com
#23782: Lazy objects don't support __contains__
-------------------------------+--------------------------------------
Reporter: Kronuz | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 1.7
Severity: Normal | Resolution: worksforme
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 mrbox):

* status: new => closed
* resolution: => worksforme


Comment:

What is more, these tests already exists in
https://github.com/django/django/blob/master/tests/utils_tests/test_lazyobject.py
The __contains__ method was added to the code in this commit:
https://github.com/django/django/commit/7a698c05b56d7d5e267241dc71c16c403efd2965

So I'm closing this issue as worksforme

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

Reply all
Reply to author
Forward
0 new messages