[Django] #23838: LazyObject is missing __iter__

25 views
Skip to first unread message

Django

unread,
Nov 15, 2014, 10:51:53 AM11/15/14
to django-...@googlegroups.com
#23838: LazyObject is missing __iter__
-------------------------------+--------------------
Reporter: rednaw | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
The `LazyObject` class in `utils.functional`
(https://github.com/django/django/blob/master/django/utils/functional.py#L235)
is missing the `__iter__` magic method.

Other dict related magic methods like `__getitem__`, `__setitem__` and
`__delitem__` are supported but not `__iter__`. I can't think of a reason
it isn't there and haven't been able to find discussions about it. The
`__getitem__`, `__setitem__` and `__delitem__` were added in this ticket:

https://code.djangoproject.com/ticket/18447

I think they just forgot `__iter__`. I'm proposing to add this. If this is
done, then tickets like these:

https://code.djangoproject.com/ticket/23783

Can be resolved with `SimpleLazyObject` (which implements `LazyObject`).

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

Django

unread,
Nov 15, 2014, 10:52:49 AM11/15/14
to django-...@googlegroups.com
#23838: LazyObject is missing __iter__
-------------------------------+--------------------------------------

Reporter: rednaw | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: master
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 rednaw):

* needs_better_patch: => 0
* version: 1.6 => master
* needs_tests: => 0
* needs_docs: => 0


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

Django

unread,
Nov 15, 2014, 10:53:44 AM11/15/14
to django-...@googlegroups.com
#23838: LazyObject is missing __iter__
-------------------------------+--------------------------------------
Reporter: rednaw | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: master
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 rednaw):

* type: Uncategorized => New feature


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

Django

unread,
Nov 15, 2014, 10:56:24 AM11/15/14
to django-...@googlegroups.com
#23838: LazyObject is missing __iter__
-------------------------------+--------------------------------------
Reporter: rednaw | Owner: rednaw
Type: New feature | Status: assigned

Component: Uncategorized | Version: master
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 rednaw):

* cc: gitaarik@… (added)
* status: new => assigned
* owner: nobody => rednaw


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

Django

unread,
Nov 15, 2014, 12:44:10 PM11/15/14
to django-...@googlegroups.com
#23838: LazyObject is missing __iter__
-------------------------------+--------------------------------------
Reporter: rednaw | Owner: rednaw
Type: New feature | Status: assigned
Component: Uncategorized | Version: master
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 rednaw):

* cc: gitaarik@… (removed)


Comment:

Created a pull request:

https://github.com/django/django/pull/3541

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

Django

unread,
Nov 16, 2014, 10:36:34 AM11/16/14
to django-...@googlegroups.com
#23838: LazyObject is missing __iter__
-----------------------------+--------------------------------------
Reporter: rednaw | Owner: rednaw
Type: New feature | Status: assigned
Component: Utilities | Version: master
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 timgraham):

* component: Uncategorized => Utilities


Comment:

As I noted on the pull request, the new tests pass even before the fix is
applied so either there is no issue here or the test needs to be modified
to actually show what issue is fixed.

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

Django

unread,
Nov 17, 2014, 11:39:07 AM11/17/14
to django-...@googlegroups.com
#23838: LazyObject is missing __iter__
--------------------------------------+------------------------------------
Reporter: rednaw | Owner: rednaw
Type: Cleanup/optimization | Status: assigned

Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* type: New feature => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

Hi,

The feature looks reasonable but as noted by Tim, the tests need some
improvement.

Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/23838#comment:6>

Django

unread,
Mar 7, 2015, 10:05:01 AM3/7/15
to django-...@googlegroups.com
#23838: LazyObject is missing __iter__
--------------------------------------+------------------------------------
Reporter: rednaw | Owner: rednaw
Type: Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by rednaw):

I updated my pull request, the test now fails when `__iter__` is not
implemented in `LazyObject`, so it's a good unit test now.

--
Ticket URL: <https://code.djangoproject.com/ticket/23838#comment:7>

Django

unread,
Mar 7, 2015, 10:08:42 AM3/7/15
to django-...@googlegroups.com
#23838: LazyObject is missing __iter__
--------------------------------------+------------------------------------
Reporter: rednaw | Owner: rednaw
Type: Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
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 rednaw):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/23838#comment:8>

Django

unread,
Mar 7, 2015, 2:17:53 PM3/7/15
to django-...@googlegroups.com
#23838: LazyObject is missing __iter__
-------------------------------------+-------------------------------------
Reporter: rednaw | Owner: rednaw
Type: | Status: assigned
Cleanup/optimization |

Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

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

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

* stage: Accepted => Ready for checkin


Comment:

New tests check for {{{__iter__}}} and fail with old implementation;
commit message is fine, lgtm.

The old test was already covered by the actual tests for
{{{__getitem__}}}.

--
Ticket URL: <https://code.djangoproject.com/ticket/23838#comment:9>

Django

unread,
Mar 8, 2015, 10:42:47 AM3/8/15
to django-...@googlegroups.com
#23838: LazyObject is missing __iter__
-------------------------------------+-------------------------------------
Reporter: rednaw | Owner: rednaw
Type: | Status: closed

Cleanup/optimization |
Component: Utilities | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Baptiste Mispelon <bmispelon@…>):

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


Comment:

In [changeset:"a5b225084f69e27b78fab0f2954fa9520656976e"]:
{{{
#!CommitTicketReference repository=""
revision="a5b225084f69e27b78fab0f2954fa9520656976e"
Fixed #23838 -- added missing `__iter__` to LazyObject
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23838#comment:10>

Reply all
Reply to author
Forward
0 new messages