]> granicus.if.org Git - python/commitdiff
Fixed bug reported to Gregor Hoffleit:
authorAndrew M. Kuchling <amk@amk.ca>
Mon, 14 Dec 1998 19:36:14 +0000 (19:36 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Mon, 14 Dec 1998 19:36:14 +0000 (19:36 +0000)
> 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.

Modules/mpzmodule.c

index e1fd7bfa4b16b5ee9657894bd56f5f46c6841f6a..7ae6937378a17a413e73d607d401d663b0d05edb 100644 (file)
@@ -969,7 +969,7 @@ MPZ_mpz(self, args)
                mpz_clear(&mplongdigit);
        }
        else if (PyString_Check(objp)) {
-               char *cp = PyString_AS_STRING(objp);
+               unsigned char *cp = (unsigned char *)PyString_AS_STRING(objp);
                int len = PyString_GET_SIZE(objp);
                MP_INT mplongdigit;