Changes to support gmpy >=1.13, or gmpy2 >=2.0.0b4