From 6b7f670c4ccb6a2c45a6da459ed29b07784498b0 Mon Sep 17 00:00:00 2001 From: Jason Kirtland Date: Wed, 1 Aug 2007 20:07:07 +0000 Subject: Stopgap for post- #646 and r3030, wedge in 0.3 Decimals-are-floats behavior for vanilla 2.3 Python. --- lib/sqlalchemy/util.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/sqlalchemy/util.py') diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py index 6cb65e395..7391d86fd 100644 --- a/lib/sqlalchemy/util.py +++ b/lib/sqlalchemy/util.py @@ -32,6 +32,22 @@ except: i -= 1 raise StopIteration() +try: + # Try the standard decimal for > 2.3 or the compatibility module + # for 2.3, if installed. + from decimal import Decimal + decimal_type = Decimal +except ImportError: + def Decimal(arg): + if Decimal.warn: + warnings.warn(RuntimeWarning( + "True Decimal types not available on this Python, " + "falling back to floats.")) + Decimal.warn = False + return float(arg) + Decimal.warn = True + decimal_type = float + if sys.version_info >= (2, 5): class PopulateDict(dict): """a dict which populates missing values via a creation function. -- cgit v1.2.1