diff options
author | Jason Kirtland <jek@discorporate.us> | 2007-08-01 20:07:07 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2007-08-01 20:07:07 +0000 |
commit | 6b7f670c4ccb6a2c45a6da459ed29b07784498b0 (patch) | |
tree | a36cfc6ec9bfe1ee8b3debb4fcce436159e622e3 /lib/sqlalchemy/util.py | |
parent | 963087faf48b42e2885e9132c1be1c1f1b4d18ef (diff) | |
download | sqlalchemy-6b7f670c4ccb6a2c45a6da459ed29b07784498b0.tar.gz |
Stopgap for post- #646 and r3030, wedge in 0.3 Decimals-are-floats behavior for vanilla 2.3 Python.
Diffstat (limited to 'lib/sqlalchemy/util.py')
-rw-r--r-- | lib/sqlalchemy/util.py | 16 |
1 files changed, 16 insertions, 0 deletions
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. |