Skip to content

Bad exception type for negative lshifts #516

@skirpichev

Description

@skirpichev

E.g. 1_120_853_924_160_859_679 << -2_147_483_649 - raises OverflowError on GraalPy-24.2. Instead of the ValueError, as does CPython.

See build log: https://github.com/diofant/python-gmp/actions/runs/16150768663/job/45581205663

  =================================== FAILURES ===================================
  _________________________________ test_lshift __________________________________
  
  x = 1120853924160859679, y = -2147483649
  
      @given(integers(), integers(max_value=12345))
      @example(18446744073709551618, 64)
      @example(1, 1<<128)
      @example(90605555449081991889354259339521952450308780844225461, 64)
      def test_lshift(x, y):
          mx = mpz(x)
          my = mpz(y)
          try:
              r = x << y
          except OverflowError:
              with pytest.raises(OverflowError):
  >               mx << my
  E               ValueError: negative shift count
  E               Falsifying example: test_lshift(
  E                   x=1_120_853_924_160_859_679,
  E                   y=-2_147_483_649,
  E               )
  E               Explanation:
  E                   These lines were always and only run by failing examples:
  E                       /project/tests/test_mpz.py:624
  
  /project/tests/test_mpz.py:625: ValueError

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions