Code

Opened 8 months ago

Closed 7 months ago

#20926 closed Bug (needsinfo)

postgresql 'infinity' raises 'OverflowError: date value out of range' if TZ is east of UTC

Reported by: tim@… Owned by: mburst
Component: Database layer (models, ORM) Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When a datetime field is set to 'infinity' by an external application, django will throw an 'OverflowError: date value out of range' when the corresponding model object is modified within django the next time. This only occurs, however, if the timezone which is set is not UTC (in my Example 'Europe/Berlin').

The problem is, that django translates infinity to the maximum allowed timestamp of 9999-12-31 23:59:59 but timezone unaware. When Django tries to make the timestamp timezone aware, it uses the local timezone as default, which makes the timestamp in UTC larger than the maximum allowed timestamp, throwing the Exception.
I would guess, that this only applies for Timezones east of UTC.

Attachments (0)

Change History (4)

comment:1 Changed 8 months ago by apollo13

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 8 months ago by claudep

  • Component changed from Uncategorized to Database layer (models, ORM)
  • Type changed from Uncategorized to Bug

comment:3 Changed 7 months ago by mburst

  • Owner changed from nobody to mburst
  • Status changed from new to assigned

comment:4 Changed 7 months ago by aaugustin

  • Resolution set to needsinfo
  • Status changed from assigned to closed

Please install pytz (as recommended by the docs) and check if the bug still happens.

If it does, please reopen the ticket and provide a complete traceback.

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.