Edgewall Software
Modify

Opened 17 years ago

Closed 16 years ago

#5322 closed defect (fixed)

ValueError raised when due date for milestone is too large

Reported by: vbs Owned by: osimons
Priority: normal Milestone: 0.11
Component: ticket system Version: devel
Severity: normal Keywords: datetime
Cc: mstepniowski@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Trac raises ValueError when you assign date from year 2038 onwards to milestone due date (*). This exception is never catched.

The problem is with this two lines, maybe more:

(*) As is stated in Python documentation:

fromtimestamp() may raise ValueError, if the timestamp is out of the range of values supported by the platform C localtime() or gmtime() functions.


Sorry for my bad english. I'm a foreign speaker.

Attachments (1)

t5322-r6317-date_valuerror-a.diff (965 bytes ) - added by osimons 16 years ago.
Patch that ensures that we can convert to and from timestamp before accepting input as a valid date.

Download all attachments as: .zip

Change History (8)

comment:1 by Christian Boos, 17 years ago

#5403 was closed as duplicate.

comment:2 by Emmanuel Blot, 17 years ago

Priority: highnormal
Severity: majornormal

comment:3 by osimons <simon-code@…>, 16 years ago

#3672 closed as duplicate.

comment:4 by osimons, 16 years ago

Owner: changed from Jonas Borgström to osimons

The 'Versions' admin page shows the same behaviour on such dates.

We need at least provide standard error pages instead of displaying the traceback.

by osimons, 16 years ago

Patch that ensures that we can convert to and from timestamp before accepting input as a valid date.

comment:5 by osimons, 16 years ago

Keywords: review datetime added
Status: newassigned

Think I found it. What happens is that we:

  • Parse the date correctly
  • We convert it to a timestamp
  • And we save it to the database

Problem is, as you correctly noticed, that it cannot be converted back if the underlying C localtime() and gmtime() functions use 32-bit ints for counting seconds since epoch. That puts the limit some time in 2038.

I've made a patch to the Trac parse_date() metod that basically does the conversion to and from timestamp, and raises an error if the date does not pass this test.

Please test t5322-r6317-date_valuerror-a.diff.

in reply to:  5 comment:6 by Christian Boos, 16 years ago

Replying to osimons:

I've made a patch to the Trac parse_date() method that basically does the conversion to and from timestamp, and raises an error if the date does not pass this test.

Great idea! That seems very robust this way. However IIUC, the error we trap in this case is not due to a wrong format, but to an out of bound condition, so the error message should rather indicate that.

comment:7 by osimons, 16 years ago

Keywords: review removed
Milestone: 0.11.10.11
Resolution: fixed
Status: assignedclosed

Fixed the error message a little, and applied in [6318].

Closing.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain osimons.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from osimons to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.