From 33268ddf7fbd71c60ebcae152e5b00f3df1d98a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 4 Jan 2012 19:54:30 +0100 Subject: [PATCH] Use cdecimal if available review185002 --- doc/topics/install.rst | 1 + setup.py | 1 + trytond/config.py | 12 +++++++++++- trytond/tests/test_exportdata.py | 8 ++++++++ trytond/tests/test_fields.py | 8 ++++++++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/doc/topics/install.rst b/doc/topics/install.rst index be508ae30f..4cfb44d0b2 100644 --- a/doc/topics/install.rst +++ b/doc/topics/install.rst @@ -20,6 +20,7 @@ Prerequisites * Optional: unoconv http://dag.wieers.com/home-made/unoconv/) * Optional: sphinx (http://sphinx.pocoo.org/) * Optional: simplejson (http://undefined.org/python/#simplejson) + * Optional: cdecimal (http://www.bytereef.org/mpdecimal/index.html) Install Tryton ============== diff --git a/setup.py b/setup.py index 6046e70bfe..34e7a4214d 100644 --- a/setup.py +++ b/setup.py @@ -71,6 +71,7 @@ setup(name=PACKAGE, 'graphviz': ['pydot'], 'timezone': ['pytz'], 'simplejson': ['simplejson'], + 'cdecimal': ['cdecimal'], }, zip_safe=False, test_suite='trytond.tests', diff --git a/trytond/config.py b/trytond/config.py index 0cdb678dbf..098462d650 100644 --- a/trytond/config.py +++ b/trytond/config.py @@ -1,6 +1,16 @@ #This file is part of Tryton. The COPYRIGHT file at the top level of #this repository contains the full copyright notices and license terms. -import ConfigParser, os, sys +import sys +try: + import cdecimal + # Use cdecimal globally + if 'decimal' not in sys.modules: + sys.modules['decimal'] = cdecimal +except ImportError: + import decimal + sys.modules['cdecimal'] = decimal +import os +import ConfigParser def get_hostname(netloc): if '[' in netloc and ']' in netloc: diff --git a/trytond/tests/test_exportdata.py b/trytond/tests/test_exportdata.py index 568f537dba..64984f76c4 100644 --- a/trytond/tests/test_exportdata.py +++ b/trytond/tests/test_exportdata.py @@ -2,6 +2,14 @@ # -*- coding: utf-8 -*- #This file is part of Tryton. The COPYRIGHT file at the top level of #this repository contains the full copyright notices and license terms. +import sys +try: + import cdecimal + if 'decimal' not in sys.modules: + sys.modules['decimal'] = cdecimal +except ImportError: + import decimal + sys.modules['cdecimal'] = decimal import unittest from decimal import Decimal import datetime diff --git a/trytond/tests/test_fields.py b/trytond/tests/test_fields.py index cf1705e39e..b068a7a121 100644 --- a/trytond/tests/test_fields.py +++ b/trytond/tests/test_fields.py @@ -2,6 +2,14 @@ # -*- coding: utf-8 -*- #This file is part of Tryton. The COPYRIGHT file at the top level of #this repository contains the full copyright notices and license terms. +import sys +try: + import cdecimal + if 'decimal' not in sys.modules: + sys.modules['decimal'] = cdecimal +except ImportError: + import decimal + sys.modules['cdecimal'] = decimal import unittest import datetime from decimal import Decimal