[Python-checkins] r46120 - sandbox/trunk/decimal-c/decimal.py
georg.brandl
python-checkins at python.org
Tue May 23 18:38:42 CEST 2006
Author: georg.brandl
Date: Tue May 23 18:38:41 2006
New Revision: 46120
Modified:
sandbox/trunk/decimal-c/decimal.py
Log:
Allow _WorkReps to be converted.
Modified: sandbox/trunk/decimal-c/decimal.py
==============================================================================
--- sandbox/trunk/decimal-c/decimal.py (original)
+++ sandbox/trunk/decimal-c/decimal.py Tue May 23 18:38:41 2006
@@ -470,6 +470,14 @@
# (-1)**_sign * _int * 10**_exp
# Special values are signified by _is_special == True
+ # HACK: to get support for converting WorkRep instances
+ def __new__(cls, value="0", context=None):
+ if isinstance(value, _WorkRep):
+ value = (value.sign, tuple(map(int, str(value.int))), int(value.exp))
+
+ return _decimal.Decimal.__new__(cls, value, context)
+
+
# # We're immutable, so use __new__ not __init__
# def __new__(cls, value="0", context=None):
# """Create a decimal point instance.
More information about the Python-checkins
mailing list