I do not know Python very well. I do not understand how it works under the hood.
If you entered a smaller exponent, your code works. E.g.
If you'd written
print(2**100000)
then the except block would have executed.
Again, I do not understand how Python works under the hood. I suspected the exponent is maybe limited to (uint32_max) 232-1 or (int32_max) 231-1. But that's not the case.
In my experimentation, the last exponent where a Value Error was thrown (and could be caught) was 2595262094 and at the next value, 2595262095, error code 9 was the result.
I suspect what happens is that the server running the code runs out of memory during the calculation sooner than it would realize that there will be a Value Error so the program crashes.
But this is just a hunch.
Also, the limit where this crash (Error Code 9) happens varies every time, as the server's resources change all the time (depending on how many users are using it, what's running on the machine, etc).