From a0fd8884ca0bd41b5daee3a5f40ca4fee149e5c5 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Tue, 20 Jan 2009 07:24:44 +0000 Subject: Issue 4998: Decimal should not subclass or register with numbers.Real. --- Lib/decimal.py | 11 +++++------ Lib/distutils/command/wininst-8.0.exe | Bin 61440 -> 73728 bytes 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Lib/decimal.py b/Lib/decimal.py index b486d36..26bc8ef 100644 --- a/Lib/decimal.py +++ b/Lib/decimal.py @@ -134,7 +134,6 @@ __all__ = [ 'setcontext', 'getcontext', 'localcontext' ] -import numbers as _numbers import copy as _copy import math as _math @@ -501,7 +500,11 @@ def localcontext(ctx=None): ##### Decimal class ####################################################### -class Decimal(_numbers.Real): +# Do not subclass Decimal from numbers.Real and do not register it as such +# (because Decimals are not interoperable with floats). See the notes in +# numbers.py for more detail. + +class Decimal(object): """Floating point class for decimal arithmetic.""" __slots__ = ('_exp','_int','_sign', '_is_special') @@ -1757,14 +1760,10 @@ class Decimal(_numbers.Real): >>> round(Decimal('Inf')) Traceback (most recent call last): ... - ... - ... OverflowError: cannot round an infinity >>> round(Decimal('NaN')) Traceback (most recent call last): ... - ... - ... ValueError: cannot round a NaN If a second argument n is supplied, self is rounded to n diff --git a/Lib/distutils/command/wininst-8.0.exe b/Lib/distutils/command/wininst-8.0.exe index 7403bfa..7407032 100644 Binary files a/Lib/distutils/command/wininst-8.0.exe and b/Lib/distutils/command/wininst-8.0.exe differ -- cgit v0.12