Edgewall Software
Modify

Opened 9 years ago

Closed 9 years ago

Last modified 5 years ago

#9188 closed defect (fixed)

AttributeError: 'NoneType' object has no attribute 'tzinfo'

Reported by: Christian Boos Owned by: Christian Boos
Priority: normal Milestone: 0.11.8
Component: general Version: 0.12dev
Severity: major Keywords: pytz, preferences
Cc: Branch:
Release Notes:
API Changes:

Description

How to Reproduce

While doing a GET operation on /prefs/datetime, Trac issued an internal error.

After installing pytz and restarting the server, changing one's timezone works but leads to the following traceback when visiting the preferences Date & Time panel (not only after the redirect, also afterwards).

Request parameters:

{'panel_id': u'datetime'}

User Agent was: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.342.8 Safari/533.2

System Information

Trac 0.12dev-r9404
Docutils 0.6
Genshi 0.6dev-r1096
psycopg2 2.0.8
Pygments 1.2.2dev-20100224
Python 2.5.2 (r252:60911, Oct 5 2008, 19:29:17)
[GCC 4.3.2]
pytz 2010g
setuptools 0.6c9
Subversion 1.5.1 (r32289)
jQuery 1.4.2

Enabled Plugins

StatusFixer r6326
TracSpamFilter 0.2.1dev-r8929
TracVote 0.1

Python Traceback

Traceback (most recent call last):
  File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 514, in _dispatch_request
    dispatcher.dispatch(req)
  File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 257, in dispatch
    content_type)
  File "build/bdist.linux-x86_64/egg/trac/web/chrome.py", line 862, in render_template
    stream.render(method, doctype=doctype, out=buffer)
  File "build/bdist.linux-x86_64/egg/genshi/core.py", line 183, in render
    return encode(generator, method=method, encoding=encoding, out=out)
  File "build/bdist.linux-x86_64/egg/genshi/output.py", line 58, in encode
    for chunk in iterator:
  File "build/bdist.linux-x86_64/egg/genshi/output.py", line 339, in __call__
    for kind, data, pos in stream:
  File "build/bdist.linux-x86_64/egg/genshi/output.py", line 826, in __call__
    for kind, data, pos in stream:
  File "build/bdist.linux-x86_64/egg/genshi/output.py", line 670, in __call__
    for kind, data, pos in stream:
  File "build/bdist.linux-x86_64/egg/genshi/output.py", line 771, in __call__
    for kind, data, pos in chain(stream, [(None, None, None)]):
  File "build/bdist.linux-x86_64/egg/genshi/output.py", line 586, in __call__
    for ev in stream:
  File "build/bdist.linux-x86_64/egg/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "build/bdist.linux-x86_64/egg/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "build/bdist.linux-x86_64/egg/trac/web/chrome.py", line 966, in _strip_accesskeys
    for kind, data, pos in stream:
  File "build/bdist.linux-x86_64/egg/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "build/bdist.linux-x86_64/egg/trac/web/chrome.py", line 955, in _generate
    for kind, data, pos in stream:
  File "build/bdist.linux-x86_64/egg/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "build/bdist.linux-x86_64/egg/genshi/template/base.py", line 592, in _include
    for event in stream:
  File "build/bdist.linux-x86_64/egg/genshi/template/markup.py", line 381, in _match
    ctxt, start=idx + 1, **vars):
  File "build/bdist.linux-x86_64/egg/genshi/template/markup.py", line 381, in _match
    ctxt, start=idx + 1, **vars):
  File "build/bdist.linux-x86_64/egg/genshi/template/markup.py", line 381, in _match
    ctxt, start=idx + 1, **vars):
  File "build/bdist.linux-x86_64/egg/genshi/template/markup.py", line 381, in _match
    ctxt, start=idx + 1, **vars):
  File "build/bdist.linux-x86_64/egg/genshi/template/markup.py", line 330, in _match
    for event in stream:
  File "build/bdist.linux-x86_64/egg/genshi/template/base.py", line 532, in _flatten
    for kind, data, pos in stream:
  File "build/bdist.linux-x86_64/egg/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "build/bdist.linux-x86_64/egg/genshi/path.py", line 588, in _generate
    subevent = next()
  File "build/bdist.linux-x86_64/egg/genshi/template/base.py", line 592, in _include
    for event in stream:
  File "build/bdist.linux-x86_64/egg/genshi/template/markup.py", line 330, in _match
    for event in stream:
  File "build/bdist.linux-x86_64/egg/genshi/template/markup.py", line 319, in _strip
    event = next()
  File "build/bdist.linux-x86_64/egg/genshi/template/base.py", line 532, in _flatten
    for kind, data, pos in stream:
  File "build/bdist.linux-x86_64/egg/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "build/bdist.linux-x86_64/egg/genshi/path.py", line 588, in _generate
    subevent = next()
  File "build/bdist.linux-x86_64/egg/genshi/template/base.py", line 592, in _include
    for event in stream:
  File "build/bdist.linux-x86_64/egg/genshi/template/markup.py", line 319, in _strip
    event = next()
  File "build/bdist.linux-x86_64/egg/genshi/template/base.py", line 532, in _flatten
    for kind, data, pos in stream:
  File "build/bdist.linux-x86_64/egg/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "build/bdist.linux-x86_64/egg/genshi/path.py", line 588, in _generate
    subevent = next()
  File "build/bdist.linux-x86_64/egg/genshi/template/base.py", line 592, in _include
    for event in stream:
  File "build/bdist.linux-x86_64/egg/genshi/template/markup.py", line 319, in _strip
    event = next()
  File "build/bdist.linux-x86_64/egg/genshi/template/base.py", line 532, in _flatten
    for kind, data, pos in stream:
  File "build/bdist.linux-x86_64/egg/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "build/bdist.linux-x86_64/egg/genshi/path.py", line 588, in _generate
    subevent = next()
  File "build/bdist.linux-x86_64/egg/genshi/template/base.py", line 592, in _include
    for event in stream:
  File "build/bdist.linux-x86_64/egg/genshi/template/markup.py", line 319, in _strip
    event = next()
  File "build/bdist.linux-x86_64/egg/genshi/template/base.py", line 552, in _flatten
    result = _eval_expr(data, ctxt, vars)
  File "build/bdist.linux-x86_64/egg/genshi/template/base.py", line 277, in _eval_expr
    retval = expr.evaluate(ctxt)
  File "build/bdist.linux-x86_64/egg/genshi/template/eval.py", line 178, in evaluate
    return eval(self.code, _globals, {'__data__': data})
  File "/tmp/.lighttpd-egg-cache-trunk/Trac-0.12dev_r9404-py2.5.egg-tmp/trac/prefs/templates/prefs_datetime.html", line 35, in <Expression u'selected_tz.tzname(None)'>
    In your time zone ${selected_tz.tzname(None)}, this would be displayed as
  File "/usr/local/virtualenv/trunk/lib/python2.5/site-packages/pytz-2010g-py2.5.egg/pytz/tzinfo.py", line 431, in tzname
    if dt.tzinfo is not self:
AttributeError: 'NoneType' object has no attribute 'tzinfo'

Attachments (0)

Change History (5)

comment:1 by Christian Boos, 9 years ago

Owner: set to Christian Boos
Status: newassigned

Seems to be a problem with newer pytz (2010g here), for my version 2009g it's working fine.

The doc for tzname says:

A tzinfo subclass's methods should therefore be prepared to accept a dt argument of None, or of class datetime. - datetime.tzinfo.tzname

So pytz seems at fault here (http://bazaar.launchpad.net/~stub/pytz/devel/revision/214).

comment:2 by Christian Boos, 9 years ago

So… [9413] was not enough, now we get:

ValueError: Not naive datetime (tzinfo is already set)
Fichier « /tmp/.lighttpd-egg-cache-trunk/Trac-0.12dev_r9418-py2.5.egg-tmp/trac/prefs/templates/prefs_datetime.html », ligne 35, dans <Expression u'selected_tz.tzname(now)'>
  In your time zone ${selected_tz.tzname(now)}, this would be displayed as
Fichier « /usr/local/virtualenv/trunk/lib/python2.5/site-packages/pytz-2010g-py2.5.egg/pytz/tzinfo.py », ligne 432, dans tznameFichier « /usr/local/virtualenv/trunk/lib/python2.5/site-packages/pytz-2010g-py2.5.egg/pytz/tzinfo.py », ligne 263, dans localize

comment:3 by Christian Boos, 9 years ago

Resolution: fixed
Status: assignedclosed

Fixed for good with r9419. I just verified that the problem also happened on 0.11-stable, so I backported the fix in r9420.

comment:4 by Christian Boos, 9 years ago

Milestone: 0.120.11.7.1

comment:5 by Ryan J Ollos, 5 years ago

Keywords: preferences added; preference removed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to as closed The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.