1# test errors operating on bignum 2 3i = 1 << 65 4 5try: 6 i << -1 7except ValueError: 8 print("ValueError") 9 10try: 11 len(i) 12except TypeError: 13 print("TypeError") 14 15try: 16 1 in i 17except TypeError: 18 print("TypeError") 19 20# overflow because arg of bytearray is being converted to machine int 21try: 22 bytearray(i) 23except OverflowError: 24 print('OverflowError') 25 26# to test conversion of negative mpz to machine int 27# (we know << will convert to machine int, even though it fails to do the shift) 28try: 29 i << (-(i >> 40)) 30except ValueError: 31 print('ValueError') 32 33try: 34 i // 0 35except ZeroDivisionError: 36 print('ZeroDivisionError') 37 38try: 39 i % 0 40except ZeroDivisionError: 41 print('ZeroDivisionError') 42