Raymond Hettinger
ed171abd93
Issue 8257: Decimal constructor to accept float.
2010-04-02 18:39:24 +00:00
Mark Dickinson
f3eeca16cb
Issue #7279 : Make Decimal('nan') hashable. Decimal('snan') remains unhashable.
...
Also rewrite the Decimal __hash__ method so that it doesn't rely on
float('inf') being valid: float('inf') could raise an exception on
platforms not using IEEE 754 arithmetic.
2010-04-02 10:35:12 +00:00
Mark Dickinson
e096e82e82
Issue #7279 : Make comparisons involving a Decimal sNaN signal InvalidOperation.
2010-04-02 10:17:07 +00:00
Mark Dickinson
99d8096c17
Issue #2531 : Make float-to-decimal comparisons return correct results.
...
Float to decimal comparison operations now return a result based on
the numeric values of the operands. Decimal.__hash__ has also been
fixed so that Decimal and float values that compare equal have equal
hash value.
2010-04-02 08:53:22 +00:00
Mark Dickinson
456e1652cf
Doctest fixes for decimal.py: add an integer-argument doctest for logical_invert; don't use integer literals with a leading zero.
2010-02-18 14:45:33 +00:00
Mark Dickinson
6d8effb1fc
Issue #7633 : Context method in the decimal module (with the exception
...
of the 'canonical' and 'is_canonical' methods) now consistently accept
integer arguments wherever a Decimal instance is accepted. Thanks
Juan José Conti for the patch.
2010-02-18 14:27:02 +00:00
Benjamin Peterson
28e369a8f8
compare types with is not ==
2010-01-25 03:58:21 +00:00
Benjamin Peterson
a617e208fc
mention from_float() in error message
2010-01-25 03:52:52 +00:00
Mark Dickinson
202eb9094c
Add missing docstring for Context.divmod. Thanks Juan José Conti.
2010-01-06 16:20:22 +00:00
Mark Dickinson
6f3900163a
Issue #7233 : Fix Decimal.shift and Decimal.rotate methods for
...
arguments with more digits than the current context precision.
Bug reported by Stefan Krah.
2009-10-29 12:11:18 +00:00
Mark Dickinson
0c67312c5c
Issue #7233 : A number of two-argument Decimal methods were failing to
...
accept ints and longs for the second argument.
2009-10-29 12:04:00 +00:00
Mark Dickinson
a7a52ab7ee
Issue #7099 : Decimal.is_normal should return True for all nonzero
...
finite non-subnormal values, even those with exponent > Emax.
2009-10-20 13:33:03 +00:00
Mark Dickinson
15ae41c2db
Issue #7048 : logb should round its result when that result doesn't fit
...
into the available precision. (Tests for this change are included in
the most recent set of testcases from the Decimal Specification site;
those testcases will be updated shortly.)
2009-10-07 19:22:05 +00:00
Mark Dickinson
5cfa8044ff
Issue #6857 : Fix Decimal formatting to be consistent with existing float
...
formatting: both are now right-aligned by default.
2009-09-08 20:20:19 +00:00
Mark Dickinson
968f1690d3
#Issue 6795: Fix infinite recursion in long(Decimal('nan')); change int(Decimal('nan')) to raise ValueError instead of either returning NaN or raising InvalidContext.
2009-09-07 18:04:58 +00:00
Mark Dickinson
491ea55f28
Issue #6850 : Fix bug in Decimal._parse_format_specifier for formats
...
with no type specifier.
2009-09-07 16:17:41 +00:00
Mark Dickinson
7a7739d75e
Issue #6794 : Fix handling of NaNs in Decimal.compare_total and
...
Decimal.compare_total_mag.
2009-08-28 13:25:02 +00:00
Mark Dickinson
4326ad8f72
Issue #6595 : Allow Decimal constructor to accept non-European decimal
...
digits, as recommended by the specification. (Backport of r74279 from
py3k.)
2009-08-02 10:59:36 +00:00
Raymond Hettinger
a016debad0
Update spec version number.
2009-04-27 21:12:27 +00:00
Mark Dickinson
b14514a153
Fix bug in _insert_thousands_sep: too much zero padding could be
...
added for 'n' formats with non-repeating thousands-separator.
2009-03-18 08:22:51 +00:00
Mark Dickinson
277859d591
Issue #2110 : Add support for thousands separator and 'n' format specifier
...
to Decimal __format__ method.
2009-03-17 23:03:46 +00:00
Mark Dickinson
b065e52bc2
Fix bug in Decimal __format__ method that swapped left and right
...
alignment.
2009-03-17 18:01:03 +00:00
Raymond Hettinger
daeceb2de8
Add a version tag to the decimal module.
2009-03-10 04:49:21 +00:00
Raymond Hettinger
2c8585b0af
Register decimals as numbers.Number
2009-02-03 03:37:03 +00:00
Mark Dickinson
e52c31450d
Remove uses of cmp from the decimal module.
2009-01-25 10:39:15 +00:00
Mark Dickinson
65808ff0c0
More Python 2.3 compatibility fixes for decimal.py.
2009-01-04 21:22:02 +00:00
Mark Dickinson
6a961637a8
Fix Decimal.from_float to use valid Python 2.3 syntax, as per
...
comments at top of decimal.py. (But note that the from_float
method itself with still not be usable before Python 2.7.)
See issue 4796 for discussion.
2009-01-04 21:10:56 +00:00
Raymond Hettinger
b7e835b820
Reapply r68191.
2009-01-03 19:08:10 +00:00
Raymond Hettinger
f4d8597a59
Issue 4796: Add from_float methods to the decimal module.
2009-01-03 19:02:23 +00:00
Mark Dickinson
4aa04db573
Issue #4812 : further renaming of internal Decimal constants, for clarity.
2009-01-03 12:07:20 +00:00
Mark Dickinson
c5de0969ca
Issue #4812 : add missing underscore prefix to some internal-use-only
...
constants in the decimal module. (Dec_0 becomes _Dec_0, etc.)
2009-01-02 23:07:08 +00:00
Facundo Batista
e29d435e0c
Issue #4084 : Fix max, min, max_mag and min_mag Decimal methods to
...
give correct results in the case where one argument is a quiet NaN
and the other is a finite number that requires rounding.
Thanks Mark Dickinson.
2008-12-11 04:19:46 +00:00
Neal Norwitz
18aa388ca0
Fix:
...
* crashes on memory allocation failure found with failmalloc
* memory leaks found with valgrind
* compiler warnings in opt mode which would lead to invalid memory reads
* problem using wrong name in decimal module reported by pychecker
Update the valgrind suppressions file with new leaks that are small/one-time
leaks we don't care about (ie, they are too hard to fix).
TBR=barry
TESTED=./python -E -tt ./Lib/test/regrtest.py -uall (both debug and opt modes)
in opt mode:
valgrind -q --leak-check=yes --suppressions=Misc/valgrind-python.supp \
./python -E -tt ./Lib/test/regrtest.py -uall,-bsddb,-compiler \
-x test_logging test_ssl test_multiprocessing
valgrind -q --leak-check=yes --suppressions=Misc/valgrind-python.supp \
./python -E -tt ./Lib/test/regrtest.py test_multiprocessing
for i in `seq 1 4000` ; do
LD_PRELOAD=~/local/lib/libfailmalloc.so FAILMALLOC_INTERVAL=$i \
./python -c pass
done
At least some of these fixes should probably be backported to 2.5.
2008-08-24 05:04:52 +00:00
Nick Coghlan
53663a695e
Issue 2235: __hash__ is once again inherited by default, but inheritance can be blocked explicitly so that collections.Hashable remains meaningful
2008-07-15 14:27:37 +00:00
Mark Dickinson
70c3289085
Replace occurrences of '\d' with '[0-9]' in Decimal regex, to make sure
...
that the behaviour of Decimal doesn't change if/when re.UNICODE becomes
assumed in Python 3.0.
Also add a check that alternative Unicode digits (e.g. u'\N{FULLWIDTH
DIGIT ONE}') are *not* accepted in a numeric string.
2008-07-02 09:37:01 +00:00
Mark Dickinson
71f3b85497
Make sure that Context traps and flags dictionaries have values 0 and 1
...
(as documented) rather than True and False.
2008-05-04 02:25:46 +00:00
Mark Dickinson
8aca9d032e
Some very minor changes to decimal.py in Python 2.6, aimed
...
at reducing the size of the diff between the 2.x decimal.py
and 3.x decimal.py and thereby making future merges easier:
- replace one instnace of an old-style raise statement
- define __div__ in terms of __truediv__ instead of the
other way around
- make wording match on an exception message
2008-05-04 02:05:06 +00:00
Mark Dickinson
1840c1abca
Backport Raymond's changes in r60508 to Python 2.6.
...
'Context flags get set, not incremented'
2008-05-03 18:23:14 +00:00
Facundo Batista
ee340e501d
Fixed some test structures. Thanks Mark Dickinson.
2008-05-02 17:39:00 +00:00
Mark Dickinson
8e85ffa4b2
Issue #2482 : Make sure that the coefficient of a Decimal
...
instance is always stored as a str instance, even
when that Decimal has been created from a unicode string.
2008-03-25 18:47:59 +00:00
Mark Dickinson
3b24ccbe7e
Issue #2478 : Decimal(sqrt(0)) failed when the decimal context
...
was not explicitly supplied.
2008-03-25 14:33:23 +00:00
Mark Dickinson
f4da77765f
Fix docstring typo.
2008-02-29 03:29:17 +00:00
Mark Dickinson
1ddf1d8482
Add __format__ method to Decimal, to support PEP 3101
2008-02-29 02:16:37 +00:00
Mark Dickinson
6a123cb782
Remove duplicate 'import re' in decimal.py
2008-02-24 18:12:36 +00:00
Raymond Hettinger
abe3237187
Fix decimal repr which should have used single quotes like other reprs.
2008-02-14 02:41:22 +00:00
Raymond Hettinger
116f72fa5c
Bring decimal a bit closer to the spec for Reals.
2008-02-12 01:18:03 +00:00
Mark Dickinson
3a94ee05f7
Typos in decimal comment and documentation
2008-02-10 15:19:58 +00:00
Mark Dickinson
2fc9263df5
Issue 1979: Make Decimal comparisons (other than !=, ==) involving NaN
...
raise InvalidOperation (and return False if InvalidOperation is trapped).
2008-02-06 22:10:50 +00:00
Raymond Hettinger
5a05364049
Add support for trunc().
2008-01-24 19:05:29 +00:00
Andrew M. Kuchling
c8acc882a9
Docstring typos
2008-01-16 00:32:03 +00:00