Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4c07f81

Browse files
committed
Fixed bug reported to Gregor Hoffleit:
> mpz.mpz('\xff') should return mpz(255). Instead it returns > mpz(4294967295L). Looks like the constructor doesn't work with strings > containing characters above chr(128). Caused by using just 'char' where 'unsigned char' should have been used.
1 parent cada293 commit 4c07f81

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Modules/mpzmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ MPZ_mpz(self, args)
969969
mpz_clear(&mplongdigit);
970970
}
971971
else if (PyString_Check(objp)) {
972-
char *cp = PyString_AS_STRING(objp);
972+
unsigned char *cp = (unsigned char *)PyString_AS_STRING(objp);
973973
int len = PyString_GET_SIZE(objp);
974974
MP_INT mplongdigit;
975975

0 commit comments

Comments
 (0)