summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_decimal.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.12] gh-80527: Change support.requires_legacy_unicode_capi() (GH-108438) ↵Miss Islington (bot)2023-08-251-2/+2
| | | | | | | | | | | | | | | | | | | | (#108446) gh-80527: Change support.requires_legacy_unicode_capi() (GH-108438) The decorator now requires to be called with parenthesis: @support.requires_legacy_unicode_capi() instead of: @support.requires_legacy_unicode_capi The implementation now only imports _testcapi when the decorator is called, so "import test.support" no longer imports the _testcapi extension. (cherry picked from commit 995f4c48e11349fbfb9233e02b732d4534d3008e) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.12] gh-106263: Fix segfault in `signaldict_repr` in `_decimal` module ↵Charlie Zhao2023-07-311-0/+30
| | | | | | | (#… (#107491) Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com> (cherry picked from commit 3979150a0d406707f6d253d7c15fb32c1e005a77)
* [3.12] gh-89392: Make test_decimal discoverable (GH-106209) (#106230)Miss Islington (bot)2023-07-051-133/+146
| | | | | | gh-89392: Make test_decimal discoverable (GH-106209) (cherry picked from commit 0e24499129f3917b199a6d46fa33eeedd2c447fc) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96499)Gregory P. Smith2022-09-021-0/+18
| | | | | | | | | | | | | | | | Integer to and from text conversions via CPython's bignum `int` type is not safe against denial of service attacks due to malicious input. Very large input strings with hundred thousands of digits can consume several CPU seconds. This PR comes fresh from a pile of work done in our private PSRT security response team repo. Signed-off-by: Christian Heimes [Red Hat] <christian@python.org> Tons-of-polishing-up-by: Gregory P. Smith [Google] <greg@krypto.org> Reviews via the private PSRT repo via many others (see the NEWS entry in the PR). <!-- gh-issue-number: gh-95778 --> * Issue: gh-95778 <!-- /gh-issue-number --> I wrote up [a one pager for the release managers](https://docs.google.com/document/d/1KjuF_aXlzPUxTK4BMgezGJ2Pn7uevfX7g0_mvgHlL7Y/edit#). Much of that text wound up in the Issue. Backports PRs already exist. See the issue for links.
* gh-95853: Address wasm build and test issues (GH-95985)Christian Heimes2022-08-151-1/+2
|
* gh-91821: Make decimal test succeed consistently (#91825)Jelle Zijlstra2022-04-241-0/+1
| | | | | | | The test relies on precision being set to 9, but some ways of invoking this test leave it set to 28 instead. I don't know exactly how it happens, but setting the precision directly should make the behavior consistent.
* gh-91291: Accept attributes as keyword arguments in decimal.localcontext ↵Sam Ezeh2022-04-221-0/+34
| | | | | (#32242) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* bpo-45995: add "z" format specifer to coerce negative 0 to zero (GH-30049)John Belmonte2022-04-111-0/+60
| | | | | | | | Add "z" format specifier to coerce negative 0 to zero. See https://github.com/python/cpython/issues/90153 (originally https://bugs.python.org/issue45995) for discussion. This covers `str.format()` and f-strings. Old-style string interpolation is not supported. Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* bpo-40280: Detect missing threading on WASM platforms (GH-32352)Christian Heimes2022-04-071-0/+3
| | | Co-authored-by: Brett Cannon <brett@python.org>
* bpo-46633: Skip tests on ASAN and/or MSAN builds (GH-31632)Victor Stinner2022-03-011-13/+3
| | | | | | | | | | | | Skip tests on ASAN and/or MSAN builds: * multiprocessing tests * test___all__ * test_concurrent_futures * test_decimal * test_peg_generator * test_tools The ASAN job of GitHub Actions no longer excludes these tests.
* bpo-46361: Fix "small" `int` caching (GH-30583)Brandt Bucher2022-01-161-0/+7
|
* bpo-40173: Fix test.support.import_helper.import_fresh_module() (GH-28654)Serhiy Storchaka2021-09-301-1/+1
| | | | | | | | | | | | * Work correctly if an additional fresh module imports other additional fresh module which imports a blocked module. * Raises ImportError if the specified module cannot be imported while all additional fresh modules are successfully imported. * Support blocking packages. * Always restore the import state of fresh and blocked modules and their submodules. * Fix test_decimal and test_xml_etree which depended on an undesired side effect of import_fresh_module().
* bpo-45196: prevent unittest crash on address sanitizer builds (GH-28331)junyixie2021-09-141-0/+13
|
* bpo-40928: notify users running test_decimal on macOS of malloc warnings ↵Jack DeVries2021-08-061-1/+6
| | | | | | | | (GH-26783) * When trying to allocate very large regions on macOS, malloc does not fail silently. It sends a noisy error out to STDERR * This provides a helper function to warn the user, and provides the warning for test_decimal, which consistently generates these warnings on macOS. Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* bpo-43475: Fix the Python implementation of hash of Decimal NaN (GH-26679)Serhiy Storchaka2021-06-121-8/+15
|
* bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25145)Inada Naoki2021-04-041-1/+1
| | | | | | | | | | | | | | | | | | | * test_asyncio * test_bz2 * test_math * test_cmath * test_cmd_line * test_cmd_line_script * test_compile * test_contextlib * test_profile * ctypes/test/test_find * test_multiprocessing * test_configparser * test_csv * test_dbm_dumb * test_decimal * test_difflib * os.fdopen() calls io.text_encoding() to emit EncodingWarning for right place.
* bpo-43422: Revert _decimal C API addition (GH-24960)Antoine Pitrou2021-03-211-176/+0
| | | | | | | | | Stefan Krah requested the reversal of these (unreleased) changes, quoting him: > The capsule API does not meet my testing standards, since I've focused on the upstream mpdecimal in the last couple of months. > Additionally, I'd like to refine the API, perhaps together with the Arrow community. Automerge-Triggered-By: GH:pitrou
* Revert "bpo-26680: Incorporate is_integer in all built-in and standard ↵Raymond Hettinger2020-10-071-24/+0
| | | | | library numeric types (GH-6121)" (GH-22584) This reverts commit 58a7da9e125422323f79c4ee95ac5549989d8162.
* bpo-26680: Incorporate is_integer in all built-in and standard library ↵Robert Smallshire2020-10-011-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | numeric types (GH-6121) * bpo-26680: Adds support for int.is_integer() for compatibility with float.is_integer(). The int.is_integer() method always returns True. * bpo-26680: Adds a test to ensure that False.is_integer() and True.is_integer() are always True. * bpo-26680: Adds Real.is_integer() with a trivial implementation using conversion to int. This default implementation is intended to reduce the workload for subclass implementers. It is not robust in the presence of infinities or NaNs and may have suboptimal performance for other types. * bpo-26680: Adds Rational.is_integer which returns True if the denominator is one. This implementation assumes the Rational is represented in it's lowest form, as required by the class docstring. * bpo-26680: Adds Integral.is_integer which always returns True. * bpo-26680: Adds tests for Fraction.is_integer called as an instance method. The tests for the Rational abstract base class use an unbound method to sidestep the inability to directly instantiate Rational. These tests check that everything works correct as an instance method. * bpo-26680: Updates documentation for Real.is_integer and built-ins int and float. The call x.is_integer() is now listed in the table of operations which apply to all numeric types except complex, with a reference to the full documentation for Real.is_integer(). Mention of is_integer() has been removed from the section 'Additional Methods on Float'. The documentation for Real.is_integer() describes its purpose, and mentions that it should be overridden for performance reasons, or to handle special values like NaN. * bpo-26680: Adds Decimal.is_integer to the Python and C implementations. The C implementation of Decimal already implements and uses mpd_isinteger internally, we just expose the existing function to Python. The Python implementation uses internal conversion to integer using to_integral_value(). In both cases, the corresponding context methods are also implemented. Tests and documentation are included. * bpo-26680: Updates the ACKS file. * bpo-26680: NEWS entries for int, the numeric ABCs and Decimal. Co-authored-by: Robert Smallshire <rob@sixty-north.com>
* bpo-41540: AIX: skip test that is flaky with a default ulimit. (#21890)Stefan Krah2020-08-151-0/+3
| | | | - AIX has extreme over-allocation that is in no relation to the physical RAM and swap.
* bpo-41324 Add a minimal decimal capsule API (#21519)Stefan Krah2020-08-101-0/+176
|
* bpo-41338: Fix DeprecationWarning in tests (GH-21542)Inada Naoki2020-07-201-0/+3
|
* bpo-36346: Make using the legacy Unicode C API optional (GH-21437)Serhiy Storchaka2020-07-101-1/+4
| | | | Add compile time option USE_UNICODE_WCHAR_CACHE. Setting it to 0 makes the interpreter not using the wchar_t cache and the legacy Unicode C API.
* bpo-40275: Use new test.support helper submodules in tests (GH-20849)Hai Shi2020-06-251-1/+2
|
* Fix missing FloatOperation in EXTRA_FUNCTIONALITY path. (#20655)Stefan Krah2020-06-051-0/+2
|
* bpo-39576: Prevent memory error for overly optimistic precisions (GH-18581)Stefan Krah2020-02-211-0/+35
|
* Remove binding of captured exceptions when not used to reduce the chances of ↵Pablo Galindo2019-11-191-2/+2
| | | | | | | creating cycles (GH-17246) Capturing exceptions into names can lead to reference cycles though the __traceback__ attribute of the exceptions in some obscure cases that have been reported previously and fixed individually. As these variables are not used anyway, we can remove the binding to reduce the chances of creating reference cycles. See for example GH-13135
* bpo-35133: Fix mistakes when concatenate string literals on different lines. ↵Serhiy Storchaka2018-11-051-2/+2
| | | | | | | | | | (GH-10284) Two kind of mistakes: 1. Missed space. After concatenating there is no space between words. 2. Missed comma. Causes unintentional concatenating in a list of strings.
* bpo-33750: Reset thread-local context precision in test_round(). (#7355)Stefan Krah2018-06-031-11/+11
|
* bpo-31234: Join threads in tests (#3572)Victor Stinner2017-09-141-0/+3
| | | | Call thread.join() on threads to prevent the "dangling threads" warning.
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-6/+3
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* bpo-29919: Remove unused imports found by pyflakes (#137)Victor Stinner2017-03-271-2/+1
| | | Make also minor PEP8 coding style fixes on modified imports.
* Fixed #29534 - _decimal difference with _pydecimal (#65)Andrew Nester2017-02-141-0/+10
|
* Remove unused imports.Serhiy Storchaka2016-12-161-2/+0
|
* Issue #26331: Implement the parsing part of PEP 515.Brett Cannon2016-09-091-0/+10
| | | | Thanks to Georg Brandl for the patch.
* Merge 3.5.Stefan Krah2016-07-171-0/+28
|\
| * Issue #26974: Fix segfault in the presence of absurd subclassing. ProactivelyStefan Krah2016-07-171-0/+28
| | | | | | | | eliminate all internal uses of overridden methods.
* | Merge 3.5.Stefan Krah2016-06-201-1/+4
|\ \ | |/
| * Issue #27006: from_float(): call the subclass' __new__() and __init__().Stefan Krah2016-06-201-1/+4
| |
| * Issue #26621: Remove unnecessary test.Stefan Krah2016-03-231-1/+0
| |
* | Issue #26621: Update libmpdec version and remove unnecessary test case.Stefan Krah2016-03-231-1/+0
| |
* | Issue #25928: Add Decimal.as_integer_ratio(). Python parts and docs byStefan Krah2015-12-281-0/+33
|/ | | | Mark Dickinson.
* Issue #22777: Test pickling with all protocols.Serhiy Storchaka2014-12-151-96/+98
|\
| * Issue #22777: Test pickling with all protocols.Serhiy Storchaka2014-12-151-96/+98
| |
* | Issue #19232: Speed up decimal import. Additionally, since _decimal isStefan Krah2014-09-101-3/+1
| | | | | | | | | | self-contained, this change facilitates maintenance and the Python version can be easily imported for experimentation.
* | Merge 3.4.Stefan Krah2014-08-261-0/+5
|\ \ | |/
| * Issue #22090: Fix '%' formatting for infinities and NaNs.Stefan Krah2014-08-261-0/+5
| |
* | Issue #18492: Merge with 3.4Zachary Ware2014-06-021-2/+2
|\ \ | |/
| * Issue #18492: Allow all resources when tests are not run by regrtest.py.Zachary Ware2014-06-021-2/+2
| | | | | | | | This changeset also includes cleanup allowed by this behavior change.
| * Issue #21374: Fix pickling of DecimalTuple.Stefan Krah2014-04-291-0/+17
| |