Commit Graph

115 Commits

Author SHA1 Message Date
Terry Jan Reedy 0f84764a09 Issue #17047: remove doubled words added in 3.3
as reported by Serhiy Storchaka and Matthew Barnett.
2013-03-11 18:34:00 -04:00
Stefan Krah eb8c451bd2 Since the return type of format() is not a Decimal, raise ValueError instead of
InvalidOperation if the format specification (width, prec) exceeds the internal
limits of libmpdec.
2013-01-24 15:22:33 +01:00
Stefan Krah 59a4a93f43 Issue #16422: Use strings for rounding mode constants for better readability
and pickling compatibility.
2013-01-16 12:58:59 +01:00
Stefan Krah 9a4ff437d1 Issue #15783: Support None default values in the Context() constructor. 2012-12-16 21:10:35 +01:00
Stefan Krah 040e311826 Issue #15783: Except for the number methods, the C version of decimal now
supports all None default values present in decimal.py. These values were
largely undocumented.
2012-12-15 22:33:33 +01:00
Stefan Krah 6e467049c6 Accept Unicode legacy strings in the Decimal constructor. 2012-11-10 23:09:04 +01:00
Stefan Krah 0f82b76b57 Issue #16431: Finally, consider all permutations. 2012-11-08 11:17:29 +01:00
Stefan Krah ed16eff57e Issue #16431: Also fix the opposite direction. 2012-11-07 23:47:19 +01:00
Stefan Krah f4abc7b8a0 Issue #16431: Use the type information when constructing a Decimal subtype
from a Decimal argument.
2012-11-07 23:12:25 +01:00
Stefan Krah 8a491a8eef Closes #16080: The decorator ignores failed attempts to set the required
locale, so an additional check is required.
2012-09-28 17:17:11 +02:00
Stefan Krah 6fb204af79 Issue #16080: Use run_with_locale() decorator to reset the locale properly. 2012-09-28 16:18:54 +02:00
Stefan Krah 76e12179c5 Issue #15882: Change _decimal to accept any coefficient tuple when
constructing infinities. This is done for backwards compatibility
with decimal.py: Infinity coefficients are undefined in _decimal
(in accordance with the specification).
2012-09-10 19:34:58 +02:00
Mark Dickinson fc33d4ce0a Issue #15544: Fix Decimal.__float__ to work with payload-carrying NaNs. 2012-08-24 18:53:10 +01:00
Stefan Krah ff3eca0cc3 Allow printing a leading '-' and the maximum number of exponent digits
rather than raising RuntimeError (allocated space is sufficient for the
additional character).
2012-04-05 15:46:19 +02:00
Stefan Krah 0774e9b9f5 Raise InvalidOperation if exponents of zeros are clamped during exact
conversion in the Decimal constructor. Exact here refers to the
representation and not to the value (clamping does not change the value).
2012-04-05 15:21:58 +02:00
Stefan Krah 9d2801095f Testing the implicit initialization of the thread local context on first
access fails (expectedly) if other modules have already used decimal. The
only option is to remove the test.
2012-04-02 19:10:20 +02:00
Stefan Krah 38548ad006 Whitespace. 2012-04-02 15:10:36 +02:00
Stefan Krah 5100171d81 Clear the context flags if a context is initialized from the DefaultContext. 2012-04-02 15:02:21 +02:00
Stefan Krah fe17b2bc77 Raise MemoryError instead of InvalidOperation/MallocError for compatibility
with decimal.py. The standard specifies InsufficientStorage (MallocError) as
a sub-condition of InvalidOperation. This allows a calculation to continue
with NaN results when allocation fails.
2012-03-25 18:59:21 +02:00
Stefan Krah b6405efd1b Use the same exception hierarchy as decimal.py. FloatOperation now also
inherits from TypeError. Cleanup in module initialization to make repeated
import failures robust.
2012-03-23 14:46:48 +01:00
Stefan Krah 1919b7e72b Issue #7652: Integrate the decimal floating point libmpdec library to speed
up the decimal module. Performance gains of the new C implementation are
between 12x and 80x, depending on the application.
2012-03-21 18:25:23 +01:00
Mark Dickinson 39411f60a2 Issue #13248, issue #8540: Remove deprecated Context._clamp attribute from Decimal module. 2011-10-24 10:31:52 +01:00
Mark Dickinson b455e58b95 Issue #12079: Decimal(0).fma(Decimal('inf'), 'not a number') should give a TypeError, not a Decimal.InvalidOperation 2011-05-22 12:53:18 +01:00
Ezio Melotti 3b3499ba69 #11565: Merge with 3.1. 2011-03-16 11:35:38 +02:00
Ezio Melotti 13925008dc #11565: Fix several typos. Patch by Piotr Kasprzyk. 2011-03-16 11:05:33 +02:00
Eric Smith 3ab08cadae Issue #10624: Use support.requires_IEEE_754 in all appropriate tests. 2010-12-04 15:17:38 +00:00
Eric Smith 984bb58000 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon. 2010-11-25 16:08:06 +00:00
Raymond Hettinger d325c4b233 Revert r86517 2010-11-21 04:08:28 +00:00
Stefan Krah d8b661dd90 Issue #10356: hash(Decimal("sNaN")) now raises ValueError instead of TypeError. 2010-11-18 15:20:34 +00:00
Stefan Krah dc817b229c Issue #10356: Decimal(-1).__hash__() should equal hash(Decimal(-1)). 2010-11-17 11:16:34 +00:00
Antoine Pitrou ea5d827b72 Merged revisions 85503 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r85503 | antoine.pitrou | 2010-10-15 00:11:44 +0200 (ven., 15 oct. 2010) | 2 lines

  More proper closing of files
........
2010-10-14 22:14:36 +00:00
Antoine Pitrou 92f60ed82a More proper closing of files 2010-10-14 22:11:44 +00:00
Mark Dickinson 0390f504ac Merged revisions 82646,82649-82650 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r82646 | mark.dickinson | 2010-07-08 18:23:40 +0100 (Thu, 08 Jul 2010) | 1 line

  In test_decimal, convert heuristic for skipping tests into an explicit skiplist.
........
  r82649 | mark.dickinson | 2010-07-08 20:03:34 +0100 (Thu, 08 Jul 2010) | 1 line

  Fix a performance issue in Decimal.pow.  Thanks Stefan Krah for finding this.
........
  r82650 | mark.dickinson | 2010-07-08 20:09:16 +0100 (Thu, 08 Jul 2010) | 1 line

  Fix misplaced exactness check that was causing unnecessary work in Decimal.__pow__.
........
2010-07-08 19:21:59 +00:00
Mark Dickinson 247900ce47 In test_decimal, convert heuristic for skipping tests into an explicit skiplist. 2010-07-08 17:23:40 +00:00
Mark Dickinson b1d8e3229c #Issue 8540: Make Context._clamp attribute public in decimal module. 2010-05-22 18:35:36 +00:00
Mark Dickinson ece0697f32 Merged revisions 80755 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r80755 | mark.dickinson | 2010-05-04 15:35:33 +0100 (Tue, 04 May 2010) | 17 lines

  Merged revisions 80753 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r80753 | mark.dickinson | 2010-05-04 15:25:50 +0100 (Tue, 04 May 2010) | 10 lines

    Issue #8567: Fix incorrect precedence of signals in Decimal module.

    When a Decimal operation raises multiple signals and more than one of
    those signals is trapped, the specification determines the order in
    which the signals should be handled.  In many cases this order wasn't
    being followed, leading to the wrong Python exception being raised.
    This commit fixes those cases, and adds extra tests.  The tests are
    only enabled when EXTENDEDERRORTESTS is True, since they involve
    rerunning each Decimal testcase several times.
  ........
................
2010-05-04 14:37:14 +00:00
Mark Dickinson c69160e808 Merged revisions 80753 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r80753 | mark.dickinson | 2010-05-04 15:25:50 +0100 (Tue, 04 May 2010) | 10 lines

  Issue #8567: Fix incorrect precedence of signals in Decimal module.

  When a Decimal operation raises multiple signals and more than one of
  those signals is trapped, the specification determines the order in
  which the signals should be handled.  In many cases this order wasn't
  being followed, leading to the wrong Python exception being raised.
  This commit fixes those cases, and adds extra tests.  The tests are
  only enabled when EXTENDEDERRORTESTS is True, since they involve
  rerunning each Decimal testcase several times.
........
2010-05-04 14:35:33 +00:00
Ezio Melotti 6607d51160 Merged revisions 79678 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r79678 | ezio.melotti | 2010-04-03 17:51:00 +0300 (Sat, 03 Apr 2010) | 1 line

  Use more specific assert* methods in test_decimal.
........
2010-04-03 14:59:49 +00:00
Mark Dickinson ac256ab284 Merged revisions 79583,79588-79589 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r79583 | mark.dickinson | 2010-04-02 09:53:22 +0100 (Fri, 02 Apr 2010) | 7 lines

  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.
........
  r79588 | mark.dickinson | 2010-04-02 11:17:07 +0100 (Fri, 02 Apr 2010) | 2 lines

  Issue #7279:  Make comparisons involving a Decimal sNaN signal InvalidOperation.
........
  r79589 | mark.dickinson | 2010-04-02 11:35:12 +0100 (Fri, 02 Apr 2010) | 6 lines

  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-03 11:08:14 +00:00
Raymond Hettinger 9679859890 Issue 8257: Decimal constructor to accept float argument. 2010-04-02 16:58:27 +00:00
Antoine Pitrou 503ab33e54 Merged revisions 79502 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r79502 | antoine.pitrou | 2010-03-30 20:49:45 +0200 (mar., 30 mars 2010) | 4 lines

  Issue #8248: Add some tests for the bool type.  Patch by Gregory Nofi.
........
2010-03-30 18:56:19 +00:00
Georg Brandl 1b37e8728c Merged revisions 78093 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78093 | georg.brandl | 2010-02-07 18:03:15 +0100 (So, 07 Feb 2010) | 1 line

  Remove unused imports in test modules.
........
2010-03-14 10:45:50 +00:00
Mark Dickinson 84230a1eb2 Merged revisions 78217-78218 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78217 | mark.dickinson | 2010-02-18 14:27:02 +0000 (Thu, 18 Feb 2010) | 5 lines

  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.
........
  r78218 | mark.dickinson | 2010-02-18 14:45:33 +0000 (Thu, 18 Feb 2010) | 1 line

  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:49:50 +00:00
Ezio Melotti e96159335f Merged revisions 77727 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r77727 | ezio.melotti | 2010-01-24 18:58:36 +0200 (Sun, 24 Jan 2010) | 1 line

  use assert[Not]IsInstance where appropriate
........
2010-01-24 19:26:24 +00:00
Benjamin Peterson 577473fe68 use assert[Not]In where appropriate
A patch from Dave Malcolm.
2010-01-19 00:09:57 +00:00
Mark Dickinson 5c2db37c20 Issue #7435: Remove duplicate int/long tests, and other
references to long in py3k.  Patch provided by flox.
2009-12-05 20:28:34 +00:00
Mark Dickinson 9050bb28f2 Merged revisions 75947 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r75947 | mark.dickinson | 2009-10-29 12:23:02 +0000 (Thu, 29 Oct 2009) | 20 lines

  Merged revisions 75943-75945 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r75943 | mark.dickinson | 2009-10-29 11:09:09 +0000 (Thu, 29 Oct 2009) | 1 line

    Fix duplicate test numbers in extra.decTest
  ........
    r75944 | mark.dickinson | 2009-10-29 12:04:00 +0000 (Thu, 29 Oct 2009) | 3 lines

    Issue #7233:  A number of two-argument Decimal methods were failing to
    accept ints and longs for the second argument.
  ........
    r75945 | mark.dickinson | 2009-10-29 12:11:18 +0000 (Thu, 29 Oct 2009) | 4 lines

    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:25:07 +00:00
Mark Dickinson a2d1fe0b84 Merged revisions 75943-75945 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r75943 | mark.dickinson | 2009-10-29 11:09:09 +0000 (Thu, 29 Oct 2009) | 1 line

  Fix duplicate test numbers in extra.decTest
........
  r75944 | mark.dickinson | 2009-10-29 12:04:00 +0000 (Thu, 29 Oct 2009) | 3 lines

  Issue #7233:  A number of two-argument Decimal methods were failing to
  accept ints and longs for the second argument.
........
  r75945 | mark.dickinson | 2009-10-29 12:11:18 +0000 (Thu, 29 Oct 2009) | 4 lines

  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:23:02 +00:00
Mark Dickinson d08fb83777 Merged revisions 75287 via svnmerge from
svn+ssh://pythondev@www.python.org/python/branches/py3k

................
  r75287 | mark.dickinson | 2009-10-08 17:30:38 +0100 (Thu, 08 Oct 2009) | 9 lines

  Merged revisions 75286 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r75286 | mark.dickinson | 2009-10-08 17:28:39 +0100 (Thu, 08 Oct 2009) | 2 lines

    Update decimal test data to the most recent set from Mike Cowlishaw.
  ........
................
2009-10-08 16:33:06 +00:00
Mark Dickinson 8a5465339e Merged revisions 75286 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r75286 | mark.dickinson | 2009-10-08 17:28:39 +0100 (Thu, 08 Oct 2009) | 2 lines

  Update decimal test data to the most recent set from Mike Cowlishaw.
........
2009-10-08 16:30:38 +00:00