py: Fix smallint modulo with negative arguments.

Addresses issue #927.