From 5819e2cbe92c0d01aa2aee1c0c932e50153277cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 20 Jan 2010 15:22:33 +0100 Subject: [PATCH] Better test to import json There is an other json module for python < 2.6 --- setup.py | 8 ++++++-- trytond/protocols/jsonrpc.py | 8 ++++---- trytond/pyson.py | 7 ++++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index 604351e9b5..562b7d2bc2 100644 --- a/setup.py +++ b/setup.py @@ -4,9 +4,14 @@ from setuptools import setup, find_packages import os +import sys execfile(os.path.join('trytond', 'version.py')) +SIMPLEJSON = [] +if sys.version_info < (2, 6): + SIMPLEJSON = ['simplejson'] + setup(name=PACKAGE, version=VERSION, description='Tryton server', @@ -46,8 +51,7 @@ setup(name=PACKAGE, 'relatorio >= 0.2.0', 'Genshi', 'python-dateutil', - 'simplejson', - ], + ] + SIMPLEJSON, extras_require={ 'PostgreSQL': ['psycopg2 >= 2.0'], 'WebDAV': ['PyWebDAV >= 0.9.3'], diff --git a/trytond/protocols/jsonrpc.py b/trytond/protocols/jsonrpc.py index 02e1a22235..c3f34ab467 100644 --- a/trytond/protocols/jsonrpc.py +++ b/trytond/protocols/jsonrpc.py @@ -6,10 +6,6 @@ from trytond.config import CONFIG import SimpleXMLRPCServer import SimpleHTTPServer import SocketServer -try: - import json -except ImportError: - import simplejson as json from xmlrpclib import Fault import threading import traceback @@ -26,6 +22,10 @@ import posixpath import urllib import datetime from decimal import Decimal +if sys.version_info < (2, 6): + import simplejson as json +else: + import json def object_hook(dct): if '__class__' in dct: diff --git a/trytond/pyson.py b/trytond/pyson.py index 67d0a2392a..9cf5dfe716 100644 --- a/trytond/pyson.py +++ b/trytond/pyson.py @@ -1,9 +1,10 @@ #This file is part of Tryton. The COPYRIGHT file at the top level of #this repository contains the full copyright notices and license terms. -try: - import json -except ImportError: +import sys +if sys.version_info < (2, 6): import simplejson as json +else: + import json import datetime