Skip to content

Commit

Permalink
Improved fix for type mismatch in GET_OB_DIGIT and related macros.
Browse files Browse the repository at this point in the history
  • Loading branch information
casevh committed Jun 3, 2024
1 parent 5fc1b24 commit 1c0d4f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/gmpy2_convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ extern "C" {
#endif

#if PY_VERSION_HEX >= 0x030C0000
# define GET_OB_DIGIT(obj) obj->long_value.ob_digit
# define _PyLong_DigitCount(obj) (obj->long_value.lv_tag >> 3)
# define GET_OB_DIGIT(obj) ((PyLongObject*)obj)->long_value.ob_digit
# define _PyLong_DigitCount(obj) (((PyLongObject*)obj)->long_value.lv_tag >> 3)
#else
# define GET_OB_DIGIT(obj) obj->ob_digit
# define _PyLong_DigitCount(obj) (_PyLong_Sign(obj)<0 ? -Py_SIZE(obj):Py_SIZE(obj))
Expand Down
2 changes: 1 addition & 1 deletion src/gmpy2_convert_gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ mpz_set_PyLong(mpz_t z, PyObject *obj)
Py_ssize_t len;
PyLongObject *templong = (PyLongObject*)obj;

len = _PyLong_DigitCount(templong);
len = _PyLong_DigitCount(obj);
negative = _PyLong_Sign(obj) < 0;

switch (len) {
Expand Down

0 comments on commit 1c0d4f3

Please sign in to comment.