Edgewall Software

Ticket #5812 (new defect)

Opened 17 months ago

Last modified 14 months ago

Spamfilter monitor exception.

Reported by: grafikrobot@… Owned by: mgood
Priority: normal Milestone: not applicable
Component: plugin/spamfilter Version: 0.10.4
Severity: normal Keywords: unicode python23
Cc:

Description

In the Boost trac we are getting a Python exception while trying to look at the spam log in the admin interface as:

Traceback (most recent call last):
  File "/opt/trac/lib/python2.3/site-packages/trac/web/main.py", line 406, in dispatch_request
    dispatcher.dispatch(req)
  File "/opt/trac/lib/python2.3/site-packages/trac/web/main.py", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "/opt/trac/boost/plugins/TracWebAdmin-0.1.2dev_r4240-py2.3.egg/webadmin/web_ui.py", line 109, in process_request
  File "build/bdist.linux-i686/egg/tracspamfilter/admin.py", line 91, in process_admin_request
  File "build/bdist.linux-i686/egg/tracspamfilter/admin.py", line 81, in render_admin_panel
  File "build/bdist.linux-i686/egg/tracspamfilter/admin.py", line 178, in _render_monitoring_panel
  File "build/bdist.linux-i686/egg/tracspamfilter/model.py", line 265, in select
  File "build/bdist.linux-i686/egg/tracspamfilter/model.py", line 272, in _from_db
  File "build/bdist.linux-i686/egg/tracspamfilter/model.py", line 82, in _decode_content
AttributeError: 'unicode' object has no attribute 'decode'

Attachments

model.py.a.patch (0.7 KB) - added by grafikrobot@… 14 months ago.
Ensure decode is called on str.
model.py.b.patch (435 bytes) - added by grafikrobot@… 14 months ago.
Handle the AttributeError? exception, and assume string is not base64 encoded.

Change History

Changed 17 months ago by eblot

Please specify which version of Trac you're using

Changed 17 months ago by grafikrobot@…

  • version set to 0.10.4

Per the link provided to the running trac instance, 0.10.4.

Changed 17 months ago by thatch

I checked on Python 2.3.5 and the unicode type indeed doesn't have a decode method in that version.

Changed 14 months ago by sid

So the suggested course of action is to upgrade to a later python version then?

Changed 14 months ago by cboos

  • keywords unicode python23 added
  • milestone set to not applicable

Changed 14 months ago by grafikrobot@…

Looking at the current code it seems there's an expectation that the DB, sqlite in the Boost case, will return "str" and not "unicode" strings. There are two "solutions" I can think of:

  • Handle the AttributeError and assume it means the result is not base64.
  • Ensure the decode('base64') is called only on an "str" object.

I'm attaching two patches for each one of those. But note that they are not tested in any form since I just don't know enough about the rest of the spamfilter context to know if they are entirely appropriate. And testing them directly on the Boost Trac install in not feasible (and I don't have an equivalent spare trac to test this on).

Changed 14 months ago by grafikrobot@…

Ensure decode is called on str.

Changed 14 months ago by grafikrobot@…

Handle the AttributeError? exception, and assume string is not base64 encoded.

Add/Change #5812 (Spamfilter monitor exception.)

Author



Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will change from mgood. Next status will be 'new'
The owner will change from mgood to anonymous. Next status will be 'assigned'
 
Note: See TracTickets for help on using tickets.