#8233 closed defect (fixed)
TypeError: a float is required
Reported by: | Owned by: | Remy Blank | |
---|---|---|---|
Priority: | normal | Milestone: | 0.12 |
Component: | general | Version: | 0.11.1 |
Severity: | normal | Keywords: | datetime |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
How to Reproduce
While doing a GET operation on /wiki/Akara
, Trac issued an internal error.
Further investigation suggested that the problem was that the wiki page's "time" was NULL in the database (and therefore None when it gets to the offending line). I'm not sure how it got that way, but this page worked just fine before my last apt-get upgrade. I've attached a patch that fixes the problem on my system by setting self.time to None in the event "time" is NULL.
Request parameters:
{'page': u'Akara'}
User Agent was: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0
System Information
Trac | 0.11.1
|
Python | 2.6.2 (release26-maint, Apr 19 2009, 02:15:38) [GCC 4.3.3]
|
setuptools | 0.6c9
|
SQLite | 3.6.10
|
pysqlite | 2.5.0
|
Genshi | 0.5.1
|
mod_python | 3.3.1
|
Pygments | 0.10
|
Subversion | 1.5.4 (r33841)
|
jQuery: | 1.2.6
|
Python Traceback
Traceback (most recent call last): File "/usr/lib/python2.6/dist-packages/trac/web/main.py", line 423, in _dispatch_request dispatcher.dispatch(req) File "/usr/lib/python2.6/dist-packages/trac/web/main.py", line 197, in dispatch resp = chosen_handler.process_request(req) File "/usr/lib/python2.6/dist-packages/trac/wiki/web_ui.py", line 114, in process_request page = WikiPage(self.env, pagename) File "/usr/lib/python2.6/dist-packages/trac/wiki/model.py", line 43, in __init__ self._fetch(name, version, db) File "/usr/lib/python2.6/dist-packages/trac/wiki/model.py", line 70, in _fetch self.time = datetime.fromtimestamp(time, utc) TypeError: a float is required
The Aforementioned Patch
--- /tmp/model.py.backup 2009-04-24 16:17:46.000000000 -0400 +++ /usr/lib/python2.6/dist-packages/trac/wiki/model.py 2009-04-24 16:24:17.000000000 -0400 @@ -67,7 +67,10 @@ version,time,author,text,comment,readonly = row self.version = int(version) self.author = author + try: self.time = datetime.fromtimestamp(time, utc) + except TypeError: + self.time = None self.text = text self.comment = comment self.readonly = readonly and int(readonly) or 0
Attachments (0)
Change History (5)
comment:1 by , 16 years ago
comment:2 by , 16 years ago
Keywords: | datetime added |
---|---|
Milestone: | → 0.11.6 |
Hm, pretty sure you'll get other errors with such a timestamp…
Maybe we could get datetime.fromtimestamp consider NULL/None as if it's 0?
comment:4 by , 15 years ago
Milestone: | next-minor-0.12.x → 0.12 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
This was fixed as part of #6466, as the from_utimestamp()
considers None
as 0.
comment:5 by , 15 years ago
Owner: | set to |
---|
Sorry! By now I should know better than to make Python patches with the -w flag. Soooo stupid. Here's a corrected one.