mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Issue 4998: Decimal should not subclass or register with numbers.Real.
This commit is contained in:
parent
7bf3a0e866
commit
a0fd8884ca
2 changed files with 5 additions and 6 deletions
|
@ -134,7 +134,6 @@ __all__ = [
|
||||||
'setcontext', 'getcontext', 'localcontext'
|
'setcontext', 'getcontext', 'localcontext'
|
||||||
]
|
]
|
||||||
|
|
||||||
import numbers as _numbers
|
|
||||||
import copy as _copy
|
import copy as _copy
|
||||||
import math as _math
|
import math as _math
|
||||||
|
|
||||||
|
@ -501,7 +500,11 @@ def localcontext(ctx=None):
|
||||||
|
|
||||||
##### Decimal class #######################################################
|
##### 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."""
|
"""Floating point class for decimal arithmetic."""
|
||||||
|
|
||||||
__slots__ = ('_exp','_int','_sign', '_is_special')
|
__slots__ = ('_exp','_int','_sign', '_is_special')
|
||||||
|
@ -1757,14 +1760,10 @@ class Decimal(_numbers.Real):
|
||||||
>>> round(Decimal('Inf'))
|
>>> round(Decimal('Inf'))
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
...
|
|
||||||
...
|
|
||||||
OverflowError: cannot round an infinity
|
OverflowError: cannot round an infinity
|
||||||
>>> round(Decimal('NaN'))
|
>>> round(Decimal('NaN'))
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
...
|
|
||||||
...
|
|
||||||
ValueError: cannot round a NaN
|
ValueError: cannot round a NaN
|
||||||
|
|
||||||
If a second argument n is supplied, self is rounded to n
|
If a second argument n is supplied, self is rounded to n
|
||||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue