Opened 4 years ago

Closed 2 years ago

Last modified 2 years ago

#10424 closed defect (fixed)

Replace proprietary tz handling

Reported by: hasienda Owned by: jun66j5
Priority: normal Component: WatchlistPlugin
Severity: normal Keywords: timezone time-stamp
Cc: rjollos Trac Release: 1.0


This traceback was been provided for advice on IRC tonight:

2012-10-03 13:53:12,425 Trac[main] ERROR: Internal Server Error:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/trac/web/", line 511, in _dispatch_request
  File "/usr/lib/python2.7/dist-packages/trac/web/", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/local/lib/python2.7/dist-packages/TracWatchlistPlugin-1.0-py2.7.egg/tracwatchlist/", line 589, in process_request
    offset =
  File "/usr/lib/python2.7/dist-packages/pytz/", line 401, in utcoffset
    dt = self.localize(dt, is_dst)
  File "/usr/lib/python2.7/dist-packages/pytz/", line 299, in localize
    raise ValueError('Not naive datetime (tzinfo is already set)')
ValueError: Not naive datetime (tzinfo is already set)

Seems like recent changes to Trac break current code, as hinted by osimons.

Better use functions from trac.util.datefmt for what is needed by the plugin.

Attachments (0)

Change History (5)

comment:1 Changed 4 years ago by hasienda

  • Cc rjollos added; anonymous removed

comment:2 Changed 4 years ago by jun66j5

I suggest the following patch to fix the issue and another issue. See trac:ticket:10863#comment:3.

  • tracwatchlist/

    592592            wldict['show_messages'] = options['show_messages_on_watchlist_page']
    594594        wldict['perm']   = req.perm
    595         offset =
     595        offset =
    596596        if offset is None:
    597597            offset = 0
    598598        else:
    599             offset = offset.seconds / 60
     599            offset = offset.days * 24 * 60 + offset.seconds / 60
    600600        wldict['tzoffset'] = offset
    601601        wldict['i18n'] = i18n_enabled
    602602        wldict['realms'] = [ r for r in settings['listoptions']['realm_order'] if r in self.realms ]

The another issue is about timezone with negative offset. In the case, utcoffset().days is -1.

$ PYTHONPATH=$PWD ~/venv/py24/bin/python
Python 2.4.3 (#1, Jun 18 2012, 08:55:31)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from trac.util.datefmt import timezone
>>> from datetime import datetime
datetime.timedelta(-1, 72000)

comment:3 Changed 2 years ago by rjollos

  • Summary changed from Replace propriatary tz handling to Replace proprietary tz handling

comment:4 Changed 2 years ago by rjollos

  • Resolution set to fixed
  • Status changed from new to closed

In 14329:

1.0.1: Fixed handling of timezone offset. Fixes #10424.

Patch by Jun Omae.

comment:5 Changed 2 years ago by rjollos

  • Owner changed from martin_s to jun66j5

Add Comment

Modify Ticket

as closed The owner will remain jun66j5.
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.