Opened 16 years ago

Closed 13 years ago

#7343 closed Bug (worksforme)

django.utils.functional.lazy fails for datetime.date.today

Reported by: anonymous Owned by: nobody
Component: Core (Other) Version: dev
Severity: Normal Keywords: lazy functional
Cc: nowellpublic@…, simon@…, jwilk@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Ramiro Morales)

When attempting to create a lazily evaluated version of datetime.date.today -- lazy(datetime.date.today, datetime.date) -- the lazy function returns an error because datetime.date.today does not have a __dict__ attribute. This used to work with the old version of lazy (my old version was from r4944).

Attachments (1)

django-update_wrapper-attribute_error.diff (624 bytes ) - added by Jakub Wilk <ubanus@…> 16 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 by Ramiro Morales, 16 years ago

Description: modified (diff)

comment:2 by Malcolm Tredinnick, 16 years ago

Triage Stage: UnreviewedSomeday/Maybe

Since lazy() is designed for internal use and the primary use is translation stuff, the recent performance improvements which may have caused this are well worth the trade-off. So if somebody wants to write a patch to handle things like this that does not increase memory usage or impact performance, we'd certainly take it (and I can imagine such a patch would be possible).

by Jakub Wilk <ubanus@…>, 16 years ago

comment:3 by Jakub Wilk <ubanus@…>, 16 years ago

Cc: ubanus@… added
Has patch: set

comment:4 by Nowell Strite, 16 years ago

Cc: nowellpublic@… added

comment:5 by Simon Law, 15 years ago

Cc: simon@… added

comment:6 by Luke Plant, 14 years ago

Severity: Normal
Type: Bug

comment:7 by Jakub Wilk, 14 years ago

Cc: jwilk@… added
Easy pickings: unset

comment:8 by ubanus@…, 14 years ago

Cc: ubanus@… removed

comment:9 by Aymeric Augustin, 13 years ago

Component: UncategorizedCore (Other)
Needs tests: set
Triage Stage: Someday/MaybeAccepted
UI/UX: unset

There's a patch, now we need tests, and a performance benchmark to ensure the impact is limited — see Malcolm's comment.

comment:10 by Claude Paroz, 13 years ago

Resolution: worksforme
Status: newclosed

In current code, this is passing with success:

    import datetime
    lazy_today = lazy(datetime.date.today, datetime.date)
    self.assertEqual(lazy_today(), datetime.date.today())
Note: See TracTickets for help on using tickets.
Back to Top