Ticket #281 (new defect)
Opened 3 years ago
Last modified 3 years ago
forward-compatible import of json/simplejson
| Reported by: | douglas | Owned by: | adam, aco, douglas |
|---|---|---|---|
| Priority: | major | Milestone: | Bugs |
| Component: | Booki | Keywords: | |
| Cc: | adam aco douglas |
Description
From Python version 2.6, simplejson is part of the standard library, under the name json.
Wherever we import simplejson, we should do a little dance like this:
try:
import json
except ImportError?:
import simplejson as json
or the other way round, trying simplejson first.
Change History
comment:1 Changed 3 years ago by douglas
Note: See
TracTickets for help on using
tickets.

A minimally invasive patch: use a utility module that contains the import logic. You can use either of these:
from booki.utils.json_wrapper import json
from booki.utils.json_wrapper import simplejson
and it will do the right thing.
http://booki-dev.flossmanuals.net/git?p=booki.git;a=commitdiff;h=3cb43456c1d604e3413aafde9e5a3ccd795c92f2