Fix possible undefined behaviour from signed overflow in struct module.

Backport of revisions 81897, 81898 and 81902 from py3k.
2 files changed