Modify

Opened 14 years ago

Closed 14 years ago

Last modified 11 years ago

#8555 closed defect (fixed)

AttributeError: 'module' object has no attribute 'dumps' due to simplejson dependency

Reported by: Jan Beilicke Owned by: Richard Liao
Priority: normal Component: TracTicketTemplatePlugin
Severity: major Keywords: json dependency
Cc: Trac Release: 0.12

Description

At first, thx for the plugin! :)

Unfortunately I cannot get it started in Trac 0.12. After compiling the plugin and setting everything up, I was able to define some basic templates. When trying to create a new ticket, Trac behaves like there is no TracTicketTemplatePlugin installed.

I realized that simplejson is required, so I installed it afterwards. No change.

The trac.log reveals an error:

2011-03-02 09:56:32,863 Trac[main] ERROR: Internal Server Error: 
Traceback (most recent call last):
  File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 513, in _dispatch_request
    dispatcher.dispatch(req)
  File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 235, in dispatch
    resp = chosen_handler.process_request(req)
  File "build/bdist.linux-x86_64/egg/tickettemplate/ttadmin.py", line 258, in process_request
    jsonstr = simplejson.dumps(result)
AttributeError: 'module' object has no attribute 'dumps'

Any hint how to solve this issue?

Thx in advance!

Attachments (0)

Change History (6)

comment:1 Changed 14 years ago by Jan Beilicke

Issue solved by always loading simplejson:

$ svn diff tickettemplate/ttadmin.py

Index: tickettemplate/ttadmin.py
===================================================================
--- tickettemplate/ttadmin.py   (revision 9909)
+++ tickettemplate/ttadmin.py   (working copy)
@@ -40,10 +40,7 @@
 import textwrap
 import urllib
 
-try: 
-    import json as simplejson 
-except ImportError: 
-    import simplejson 
+import simplejson
 
 from tickettemplate.model import schema, schema_version, TT_Template

The machine still got Python 2.5.2 installed. json should only be available with Python 2.6 (according to the Python docs). Side note: I was able to install python-json on the system and it was used somehow:

Python 2.5.2 (r252:60911, Jan 24 2010, 17:44:40) 
[...]
>>> import json
>>> json
<module 'json' from '/usr/lib/python2.5/site-packages/json.pyc'>
>>> json.dumps
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'dumps'
>>>

The ticket can be closed, except you want to address this compatibility issue somehow.

comment:2 Changed 14 years ago by Steffen Hoffmann

Keywords: json dependency added
Severity: blockermajor
Summary: Plugin not working: AttributeError: 'module' object has no attribute 'dumps'AttributeError: 'module' object has no attribute 'dumps' due to simplejson dependency

I've found several json packages non-functional due to this error too.

But after some fiddling with several json variants I've got it to work with just simplejson on Debian 5.0, IIRC. One year later, now on Debian 6.0, this is no longer needed as the Python standard version is not 2.5 but 2.6 and I confirm that json is provided as a standard module now.

All in all this should really be manageable, not a blocker issue. Nevertheless we should enhance the wiki for all the older distributions still around with Python2.4 and 2.5 in production? Only I can't test anymore, since I've not managed to setup (virtual) test environments with that older Python versions.

comment:3 Changed 14 years ago by Richard Liao

Resolution: fixed
Status: newclosed

(In [9957]) Fixed #8555 import json when python above 2.6, otherwise import simplejson

comment:4 Changed 14 years ago by Steffen Hoffmann

Awsome response time. Thank you very much for taking care.

comment:5 in reply to:  3 Changed 14 years ago by Jan Beilicke

Replying to richard:

(In [9957]) Fixed #8555 import json when python above 2.6, otherwise import simplejson

Thanks a lot!

comment:6 Changed 11 years ago by Ryan J Ollos

In 13633:

0.8: Bump version to 0.8. Added SVN revision to egg. Refs #6589, #6809, #7311, #7404, #7440, #8555, #8609, #9238, #10858.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Richard Liao.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.