Reviewers: ,
Please review this at http://codereview.tryton.org/185002/ Affected files: M trytond/config.py M trytond/protocols/datatype.py M trytond/tests/test_exportdata.py M trytond/tests/test_fields.py M trytond/tests/test_protocols_datatype.py Index: trytond/config.py =================================================================== --- a/trytond/config.py +++ b/trytond/config.py @@ -1,6 +1,13 @@ #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 +try: + import cdecimal + # Use cdecimal globally + if 'decimal' not in sys.modules: + sys.modules["decimal"] = cdecimal +except ImportError: + pass def get_hostname(netloc): if '[' in netloc and ']' in netloc: Index: trytond/protocols/datatype.py =================================================================== --- a/trytond/protocols/datatype.py +++ b/trytond/protocols/datatype.py @@ -3,13 +3,14 @@ import decimal from decimal import Decimal -_convert_other = decimal._convert_other +if hasattr(decimal, '_convert_other'): + _convert_other = decimal._convert_other -def _convert_Float(other, *args, **kwargs): - if isinstance(other, Float): - return other.decimal - return _convert_other(other, *args, **kwargs) -decimal._convert_other = _convert_Float + def _convert_Float(other, *args, **kwargs): + if isinstance(other, Float): + return other.decimal + return _convert_other(other, *args, **kwargs) + decimal._convert_other = _convert_Float class Float(float): Index: trytond/tests/test_exportdata.py =================================================================== --- a/trytond/tests/test_exportdata.py +++ b/trytond/tests/test_exportdata.py @@ -3,6 +3,13 @@ #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 unittest +import sys +try: + import cdecimal + if 'decimal' not in sys.modules: + sys.modules["decimal"] = cdecimal +except ImportError: + pass from decimal import Decimal import datetime from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT, \ Index: trytond/tests/test_fields.py =================================================================== --- a/trytond/tests/test_fields.py +++ b/trytond/tests/test_fields.py @@ -4,6 +4,13 @@ #this repository contains the full copyright notices and license terms. import unittest import datetime +import sys +try: + import cdecimal + if 'decimal' not in sys.modules: + sys.modules["decimal"] = cdecimal +except ImportError: + pass from decimal import Decimal from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT, \ install_module Index: trytond/tests/test_protocols_datatype.py =================================================================== --- a/trytond/tests/test_protocols_datatype.py +++ b/trytond/tests/test_protocols_datatype.py @@ -10,6 +10,12 @@ sys.path.insert(0, os.path.dirname(DIR)) import unittest +try: + import cdecimal + if 'decimal' not in sys.modules: + sys.modules["decimal"] = cdecimal +except ImportError: + pass from decimal import Decimal from trytond.protocols.datatype import Float -- [email protected] mailing list
