Opened 10 years ago
Closed 10 years ago
#23782 closed Uncategorized (worksforme)
Lazy objects don't support __contains__
Reported by: | German M. Bravo | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 1.7 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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('/'))
Attachments (1)
Change History (3)
by , 10 years ago
Attachment: | #23782-lazy_with_contains.diff added |
---|
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
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
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