Skip to content
forked from aleaxit/gmpy

Commit

Permalink
Drop workaround for CPython 3.13, see python/cpython#112115
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Jan 30, 2024
1 parent 95a4ed2 commit 4b5ef78
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 43 deletions.
38 changes: 0 additions & 38 deletions src/gmpy2_convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,44 +154,6 @@ extern "C" {
# define _PyLong_DigitCount(obj) (_PyLong_IsNegative(obj)? -Py_SIZE(obj):Py_SIZE(obj))
#endif

#if PY_VERSION_HEX >= 0x030D0000

#define MAX_LONG_DIGITS \
((PY_SSIZE_T_MAX - offsetof(PyLongObject, long_value.ob_digit))/sizeof(digit))

PyLongObject *
_PyLong_New(Py_ssize_t size)
{
assert(size >= 0);
PyLongObject *result;
if (size > (Py_ssize_t)MAX_LONG_DIGITS) {
PyErr_SetString(PyExc_OverflowError,
"too many digits in integer");
return NULL;
}
/* Fast operations for single digit integers (including zero)
* assume that there is always at least one digit present. */
Py_ssize_t ndigits = size ? size : 1;
/* Number of bytes needed is: offsetof(PyLongObject, ob_digit) +
sizeof(digit)*size. Previous incarnations of this code used
sizeof() instead of the offsetof, but this risks being
incorrect in the presence of padding between the header
and the digits. */
result = PyObject_Malloc(offsetof(PyLongObject, long_value.ob_digit) +
ndigits*sizeof(digit));
if (!result) {
PyErr_NoMemory();
return NULL;
}
_PyLong_SetSignAndDigitCount(result, size != 0, size);
PyObject_Init((PyObject*)result, &PyLong_Type);
/* The digit has to be initialized explicitly to avoid
* use-of-uninitialized-value. */
result->long_value.ob_digit[0] = 0;
return result;
}
#endif

/* Since the macros are used in gmpy2's codebase, these functions are skipped
* until they are needed for the C API in the future.
*/
Expand Down
5 changes: 0 additions & 5 deletions src/gmpy2_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
* License along with GMPY2; if not, see <http://www.gnu.org/licenses/> *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#if PY_VERSION_HEX >= 0x030D0000
# define Py_BUILD_CORE
# include <internal/pycore_pyhash.h>
#endif

static Py_hash_t
GMPy_MPZ_Hash_Slot(MPZ_Object *self)
{
Expand Down

0 comments on commit 4b5ef78

Please sign in to comment.