Modify ↓
Opened 8 years ago
Last modified 15 months ago
#12825 new defect
OverflowError is raised from to_datetime()
Reported by: | Jun Omae | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | next-stable-1.6.x |
Component: | timeline | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description (last modified by )
to_datetime()
has an issue while invoking pytz.tzinfo.normalize()
: /timeline?from=0001-01-01T01:00:00Z&daysback=0
Traceback (most recent call last): File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 567, in _dispatch_request dispatcher.dispatch(req) File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 249, in dispatch resp = chosen_handler.process_request(req) File "build/bdist.linux-x86_64/egg/trac/timeline/web_ui.py", line 181, in process_request timedelta(days=daysback + 1), req.tz) File "build/bdist.linux-x86_64/egg/trac/util/datefmt.py", line 177, in to_datetime return tz.normalize(dt) File "build/bdist.linux-x86_64/egg/trac/util/datefmt.py", line 1049, in normalize return self.fromutc(dt.replace(tzinfo=self) - dt.utcoffset()) OverflowError: date value out of range
ValueError
also can be raised.
>>> from trac.util.datefmt import to_datetime >>> to_datetime(-10000000000000000000) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/venv/trac/1.0.13/lib/python2.5/site-packages/trac/util/datefmt.py", line 170, in to_datetime dt = datetime.fromtimestamp(integer - 1, tz) + \ ValueError: year is out of range >>> to_datetime(+10000000000000000000) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/venv/trac/1.0.13/lib/python2.5/site-packages/trac/util/datefmt.py", line 173, in to_datetime dt = datetime.fromtimestamp(t, tz) ValueError: year is out of range
I think we should catch ValueError
and OverflowError
, and raise a TracError
(TracValueError
if 1.2.1+) rather than.
Another case, timeline module has the same issue: /timeline?from=0001-01-01T01:00:00Z&daysback=3
Traceback (most recent call last): File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 567, in _dispatch_request dispatcher.dispatch(req) File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 249, in dispatch resp = chosen_handler.process_request(req) File "build/bdist.linux-x86_64/egg/trac/timeline/web_ui.py", line 181, in process_request timedelta(days=daysback + 1), req.tz) OverflowError: date value out of range
Attachments (0)
Change History (7)
comment:1 by , 8 years ago
Description: | modified (diff) |
---|
comment:2 by , 7 years ago
Milestone: | next-stable-1.0.x → 1.0.17 |
---|
comment:3 by , 6 years ago
Milestone: | 1.0.17 → 1.0.18 |
---|
comment:4 by , 6 years ago
Milestone: | 1.0.18 → next-stable-1.0.x |
---|
comment:5 by , 5 years ago
Milestone: | next-stable-1.0.x → 1.0.20 |
---|
comment:6 by , 5 years ago
Milestone: | 1.0.20 → next-stable-1.4.x |
---|
Note:
See TracTickets
for help on using tickets.
Assigning to 1.0.17, since I hope that to be the last 1.0.x release unless major defects or security issues arise.