Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid OverflowError in mpz.__rshift__() #525

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
path-type: inherit
if: ${{ matrix.os == 'windows-2022' }}
- name: Build wheels
uses: pypa/cibuildwheel@v2.18.0
uses: pypa/cibuildwheel@v2.21.3
env:
CIBW_PRERELEASE_PYTHONS: True
CIBW_SKIP: pp* *-win32
Expand Down
1 change: 0 additions & 1 deletion scripts/cibw_before_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ curl -s -O https://ftp.gnu.org/gnu/gmp/gmp-${GMP_VERSION}.tar.xz
tar -xf gmp-${GMP_VERSION}.tar.xz
cd gmp-${GMP_VERSION}
# Patch the mp_bitcnt_t to "unsigned long long int" on WINDOWS AMD64:
patch -N -Z -p0 < ../scripts/mp_bitcnt_t.diff
patch -N -Z -p0 < ../scripts/fat_build_fix.diff
# config.guess uses microarchitecture and configfsf.guess doesn't
# We replace config.guess with configfsf.guess to avoid microarchitecture
Expand Down
25 changes: 0 additions & 25 deletions scripts/mp_bitcnt_t.diff

This file was deleted.

14 changes: 12 additions & 2 deletions src/gmpy2_mpz_bitops.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,18 @@ GMPy_MPZ_Rshift_Slot(PyObject *self, PyObject *other)
MPZ_Object *result, *tempx;

count = GMPy_Integer_AsMpBitCnt(other);
if ((count == (mp_bitcnt_t)(-1)) && PyErr_Occurred())
return NULL;
if ((count == (mp_bitcnt_t)(-1)) && PyErr_Occurred()) {
if (!PyErr_ExceptionMatches(PyExc_OverflowError)) {
/* LCOV_EXCL_START */
return NULL;
/* LCOV_EXCL_STOP */
}
PyErr_Clear();
if (PyLong_IsNegative(other)) {
VALUE_ERROR("negative shift count");
return NULL;
}
}

if (!(result = GMPy_MPZ_New(NULL)))
return NULL;
Expand Down
Loading
Loading