Edgewall Software

Ticket #5939 (closed defect: invalid)

Opened 17 months ago

Last modified 16 months ago

float conversion bug in util/datefmt.py

Reported by: v.dijk.bas@… Owned by: cboos
Priority: normal Milestone:
Component: version control Version: 0.10.4
Severity: major Keywords:
Cc: lele@…

Description

When I try to "Browse Source" I get the following error:

Python Traceback

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/trac/web/main.py", line 406, in dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.5/site-packages/trac/web/main.py", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/lib/python2.5/site-packages/trac/versioncontrol/web_ui/browser.py", line 143, in process_request
    self._render_directory(req, repos, node, rev)
  File "/usr/lib/python2.5/site-packages/trac/versioncontrol/web_ui/browser.py", line 168, in _render_directory
    changes = get_changes(self.env, repos, [i['rev'] for i in info])
  File "/usr/lib/python2.5/site-packages/trac/versioncontrol/web_ui/util.py", line 67, in get_changes
    'date': format_datetime(changeset.date),
  File "/usr/lib/python2.5/site-packages/trac/util/datefmt.py", line 58, in format_datetime
    t = time.localtime(float(t))
TypeError: float() argument must be a string or a number

I'm using trac-0.10.4 on Gentoo with python-2.5.1. I use the latest (directly from darcs) Darcs plugin for my repository.

This is the code on my system where the error occurs: File "/usr/lib/python2.5/site-packages/trac/util/datefmt.py", line 58

def format_datetime(t=None, format='%x %X', gmt=False):
    if t is None:
        t = time.time()
    if not isinstance(t, (list, tuple, time.struct_time)):
        if gmt:
            t = time.gmtime(float(t))
        else:
            t = time.localtime(float(t)) # <<<<<<< Line 58 !!!

    text = time.strftime(format, t)
    encoding = locale.getpreferredencoding() or sys.getdefaultencoding()
    if sys.platform != 'win32':
        encoding = locale.getlocale(locale.LC_TIME)[1] or encoding
        # the above is broken on win32, e.g. we'd get '437' instead of 'cp437'                                                                                                                                    
    return unicode(text, encoding, 'replace')

I think the following code from the Darcs Plugin is also relevant because here the time 't' is constructed:

http://darcs.arstecnica.it/trac-darcs/tracdarcs/repository.py

regards,

Bas van Dijk

Attachments

Change History

Changed 17 months ago by eblot

  • version set to 0.10.4

Changed 16 months ago by cboos

  • status changed from new to closed
  • resolution set to invalid

Looks like you're using a 0.11 plugin with Trac 0.10.4. That's not supported and you'll probably quickly get into other problem than this use of a datetime object for representing a date (see the API changes for 0.11).

Look for a 0.10 compatible version of the Darcs plugin.

Add/Change #5939 (float conversion bug in util/datefmt.py)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from cboos. Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.