Opened 7 years ago

Closed 3 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: master
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)

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@…> 7 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 7 years ago by ramiro

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 7 years ago by mtredinnick

  • Triage Stage changed from Unreviewed to Someday/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).

Changed 7 years ago by Jakub Wilk <ubanus@…>

comment:3 Changed 7 years ago by Jakub Wilk <ubanus@…>

  • Cc ubanus@… added
  • Has patch set

comment:4 Changed 6 years ago by nbstrite

  • Cc nowellpublic@… added

comment:5 Changed 5 years ago by sfllaw

  • Cc simon@… added

comment:6 Changed 4 years ago by lukeplant

  • Severity set to Normal
  • Type set to Bug

comment:7 Changed 4 years ago by jwilk

  • Cc jwilk@… added
  • Easy pickings unset

comment:8 Changed 4 years ago by ubanus@…

  • Cc ubanus@… removed

comment:9 Changed 3 years ago by aaugustin

  • Component changed from Uncategorized to Core (Other)
  • Needs tests set
  • Triage Stage changed from Someday/Maybe to Accepted
  • 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 Changed 3 years ago by claudep

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

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