Commit Graph

205 Commits

Author SHA1 Message Date
Erlend Egeberg Aasland
fe9f446afe bpo-41798: Allocate _decimal extension module C API on the heap (GH-24117) 2021-01-06 12:47:28 +01:00
Victor Stinner
32bd68c839 bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587)
No longer use deprecated aliases to functions:

* Replace PyObject_MALLOC() with PyObject_Malloc()
* Replace PyObject_REALLOC() with PyObject_Realloc()
* Replace PyObject_FREE() with PyObject_Free()
* Replace PyObject_Del() with PyObject_Free()
* Replace PyObject_DEL() with PyObject_Free()
2020-12-01 10:37:39 +01:00
Serhiy Storchaka
fb5db7ec58 bpo-42006: Stop using PyDict_GetItem, PyDict_GetItemString and _PyDict_GetItemId. (GH-22648)
These functions are considered not safe because they suppress all internal errors
and can return wrong result.  PyDict_GetItemString and _PyDict_GetItemId can
also silence current exception in rare cases.

Remove no longer used _PyDict_GetItemId.
Add _PyDict_ContainsId and rename _PyDict_Contains into
_PyDict_Contains_KnownHash.
2020-10-26 08:43:39 +02:00
Raymond Hettinger
4e0ce82058 Revert "bpo-26680: Incorporate is_integer in all built-in and standard library numeric types (GH-6121)" (GH-22584)
This reverts commit 58a7da9e12.
2020-10-07 16:43:44 -07:00
Robert Smallshire
58a7da9e12 bpo-26680: Incorporate is_integer in all built-in and standard library 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>
2020-10-01 17:30:08 +01:00
Stefan Krah
40e700ad04 bpo-40878: xlc cannot handle C99 extern inline. (GH-21887)
This applies to the default "extc99" mode.  Python does not compile with "stdc99".
2020-08-15 16:06:21 +02:00
Stefan Krah
6e0b788881 Catch all skip_handler cases (GH-21842) 2020-08-12 16:00:05 +02:00
Stefan Krah
b5f87b93a5 Call randseed() before other imports in deccheck.py (GH-21834) 2020-08-11 21:14:51 +02:00
Stefan Krah
85fdafa6ea Replace import_fresh_module in decimal test files (GH-21815) 2020-08-10 21:54:50 +02:00
Stefan Krah
39042e00ab bpo-41324 Add a minimal decimal capsule API (#21519) 2020-08-10 16:32:21 +02:00
Stefan Krah
9b9f158275 bpo-41369 Update to libmpdec-2.5.1: new features (GH-21593) 2020-07-22 21:54:42 +02:00
Felix Yan
015efdbef7 bpo-41302: Fix build with system libmpdec (GH-21481)
Move definition of UNUSED from modified headers of libmpdec to
_decimal.c itself. This makes the vendored source closer to the
standalone library and fixes build with --with-system-libmpdec.

Tested to build fine with either system libmpdec or the vendored one.
2020-07-15 14:14:11 +02:00
Lawrence D'Anna
604d95e235 bpo-41100: fix _decimal for arm64 Mac OS (GH-21228)
Patch by Lawrence Danna.
2020-06-30 11:15:46 +02:00
Stefan Krah
8bea91b5e9 bpo-40874 Update the required libmpdec version for the decimal module (GH-21202) 2020-06-28 22:01:01 +02:00
Stefan Krah
951d680d56 Add multicore support to deccheck.py. (GH-20731) 2020-06-08 19:33:12 +02:00
Stefan Krah
087d612efe bpo-40874: Update to libmpdec-2.5.0 (GH-20652) 2020-06-05 19:43:01 +02:00
Victor Stinner
4a21e57fe5 bpo-40268: Remove unused structmember.h includes (GH-19530)
If only offsetof() is needed: include stddef.h instead.

When structmember.h is used, add a comment explaining that
PyMemberDef is used.
2020-04-15 02:35:41 +02:00
Victor Stinner
62183b8d6d bpo-40268: Remove explicit pythread.h includes (#19529)
Remove explicit pythread.h includes: it is always included
by Python.h.
2020-04-15 02:04:42 +02:00
Serhiy Storchaka
cd8295ff75 bpo-39943: Add the const qualifier to pointers on non-mutable PyUnicode data. (GH-19345) 2020-04-11 10:48:40 +03:00
Stefan Krah
eb47fd58ab Cosmetic change to match the surrounding code. (#18704) 2020-02-29 20:07:48 +01:00
Stefan Krah
815280eb16 bpo-39794: Add --without-decimal-contextvar (#18702) 2020-02-29 19:43:42 +01:00
Stefan Krah
90930e6545 bpo-39576: Prevent memory error for overly optimistic precisions (GH-18581) 2020-02-21 01:52:47 +01:00
Stefan Krah
1246d89203 Use the new recommended number of repetitions in the refleak tests. (#18569) 2020-02-20 19:08:53 +01:00
Stefan Krah
9b833e00e4 Update runall.bat to the latest Windows build system. (#18571) 2020-02-20 19:07:31 +01:00
Stefan Krah
c0cb8beb38 Valgrind no longer supports --db-attach=yes. (#18568) 2020-02-20 14:39:14 +01:00