Modify ↓
#2247 closed defect (worksforme)
TypeError: can't compare datetime.datetime to float
Reported by: | George Sudarkoff | Owned by: | Herbert Valerio Riedel |
---|---|---|---|
Priority: | normal | Component: | GitPlugin |
Severity: | critical | Keywords: | |
Cc: | Trac Release: | 0.11 |
Description
How to Reproduce
While doing a GET operation on /browser
, Trac issued an internal error.
Request parameters:
{'path': '/'}
System Information
Trac | 0.11dev-r6139
|
Python | 2.4.3 (#2, Oct 6 2006, 08:02:16) [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)]
|
setuptools | 0.6c1
|
SQLite | 3.2.8
|
pysqlite | 2.0.5
|
Genshi | 0.4.4
|
Python Traceback
Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/Trac-0.11dev_r6139-py2.4.egg/trac/web/main.py", line 386, in dispatch_request dispatcher.dispatch(req) File "/usr/lib/python2.4/site-packages/Trac-0.11dev_r6139-py2.4.egg/trac/web/main.py", line 195, in dispatch resp = chosen_handler.process_request(req) File "/usr/lib/python2.4/site-packages/Trac-0.11dev_r6139-py2.4.egg/trac/versioncontrol/web_ui/browser.py", line 358, in process_request node.get_properties()), File "/usr/lib/python2.4/site-packages/Trac-0.11dev_r6139-py2.4.egg/trac/versioncontrol/web_ui/browser.py", line 400, in _render_dir timerange.insert(dt) File "/usr/lib/python2.4/site-packages/Trac-0.11dev_r6139-py2.4.egg/trac/versioncontrol/web_ui/browser.py", line 178, in insert self.oldest = min(self.oldest, datetime) TypeError: can't compare datetime.datetime to float
Attachments (0)
Change History (6)
comment:1 Changed 17 years ago by
comment:2 follow-up: 3 Changed 17 years ago by
I take that back, there is a more straightforward fix. git_fs.py returns floats, but trac wants datetimes. git_fs.py gets
import datetime as datetime from trac.util.datefmt import utc
at the top, and the line
Changeset.__init__(self, sha, msg, user,time))
becomes
Changeset.__init__(self, sha, msg, user,datetime.fromtimestamp(float(time), utc))
comment:3 follow-up: 4 Changed 17 years ago by
Replying to straszheim:
I take that back, there is a more straightforward fix. git_fs.py returns floats, but trac wants datetimes. git_fs.py gets
import datetime as datetime from trac.util.datefmt import utcat the top, and the line
Changeset.__init__(self, sha, msg, user,time))becomes
Changeset.__init__(self, sha, msg, user,datetime.fromtimestamp(float(time), utc))
Results in
Trac detected an internal error: AttributeError: 'module' object has no attribute 'fromtimestamp'
here.
Trac | 0.11dev-r6417
|
Python | 2.5.1
|
setuptools | 0.6c1
|
SQLite | 3.4.1
|
pysqlite | 2.3.5
|
comment:4 follow-up: 5 Changed 17 years ago by
Try using
Changeset.__init__(self, sha, msg, user, datetime.datetime.fromtimestamp(float(time), utc))
Replying to hoodow@moonitor.org:
Results in
Trac detected an internal error:
AttributeError: 'module' object has no attribute 'fromtimestamp'
here.
comment:5 Changed 17 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
Replying to anonymous:
Try using
Changeset.__init__(self, sha, msg, user, datetime.datetime.fromtimestamp(float(time), utc))
Works, thanks.
Note: See
TracTickets for help on using
tickets.
browser.py's class TimeRange needs to convert from floats to datetime objects in the same timezone. I don't understand this hack-fix but it does work on 0.11b1.
so just convert those floats using datetime.fromtimestamp