Opened 6 years ago

Closed 3 years ago

Last modified 3 years ago

#10424 closed defect (fixed)

Replace proprietary tz handling

Reported by: Steffen Hoffmann Owned by: Jun Omae
Priority: normal Component: WatchlistPlugin
Severity: normal Keywords: timezone time-stamp
Cc: Ryan J Ollos 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 6 years ago by Steffen Hoffmann

Cc: Ryan J Ollos added; anonymous removed

comment:2 Changed 6 years ago by Jun Omae

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 3 years ago by Ryan J Ollos

Summary: Replace propriatary tz handlingReplace proprietary tz handling

comment:4 Changed 3 years ago by Ryan J Ollos

Resolution: fixed
Status: newclosed

In 14329:

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

Patch by Jun Omae.

comment:5 Changed 3 years ago by Ryan J Ollos

Owner: changed from Martin Scharrer to Jun Omae

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Jun Omae.
The resolution will be deleted.

Add Comment

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

Note: See TracTickets for help on using tickets.