Code

Opened 8 months ago

Closed 8 months ago

#20924 closed Bug (fixed)

LazyObject missing __contains__ and __len__ proxy

Reported by: nickbruun Owned by: nobody
Component: Utilities Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

django.utils.functionals.LazyObject does not proxy the __contains__ and __len__ data methods. This means that the following use cases for lazy objects that return lists, sets or dicts are not possible:

key in lazy_object
len(lazy_object)

Fixing this is trivial as has been shown by the current proxying implementation of __getitem__, __setitem__ and __delitem__. Regression test and patch is available on Github at https://github.com/nickbruun/django.

Attachments (0)

Change History (6)

comment:1 in reply to: ↑ description Changed 8 months ago by nickbruun

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 8 months ago by timo

  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

Please untick "Patch needs improvement" when you can update the PR per the comment, thanks!

comment:3 Changed 8 months ago by nickbruun

  • Patch needs improvement unset

comment:4 Changed 8 months ago by nickbruun

  • Patch needs improvement set

comment:5 Changed 8 months ago by nickbruun

  • Patch needs improvement unset

Patch updated.

comment:6 Changed 8 months ago by anonymous

  • Resolution set to fixed
  • Status changed from new to closed

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.