]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Make mpz's .binary() work on 64 bit platforms
authorMoshe Zadka <moshez@math.huji.ac.il>
Sat, 31 Mar 2001 10:55:47 +0000 (10:55 +0000)
committerMoshe Zadka <moshez@math.huji.ac.il>
Sat, 31 Mar 2001 10:55:47 +0000 (10:55 +0000)
Make mpzmodule compile with cygwin

Misc/NEWS
Modules/mpzmodule.c

index 957d22ab04f356608e6ecc0ac56b15be1df1b7ee..7651974a6660b9f4ae5c594e11ec428e1ef9bf88 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -100,6 +100,9 @@ http://sourceforge.net/tracker/index.php?func=detail&aid=<id>&group_id=5470&atid
 
 - #125375 - parsermodule.c - fix parser.tuple2ast() failure on valid parse tree
 
+- mpzmodule.c - make .binary() work on 64-bit system, make it compile with 
+  Cygwin
+
 What's New in Python 2.0?
 =========================
 
index 2cce2ccf946e036656117ea965a1db56876ee689..7a782996ece83c783f346c1b44e7746f86af5d3e 100644 (file)
@@ -1477,6 +1477,12 @@ mpz_binary(mpzobject *self, PyObject *args)
                *cp++ = (unsigned char)((ldigit >>= 8) & 0xFF);
                *cp++ = (unsigned char)((ldigit >>= 8) & 0xFF);
                *cp++ = (unsigned char)((ldigit >>= 8) & 0xFF);
+               if (sizeof(ldigit) == 8 && BITS_PER_MP_LIMB == 64) {
+                       *cp++ = (unsigned char)((ldigit >>= 8) & 0xFF);
+                       *cp++ = (unsigned char)((ldigit >>= 8) & 0xFF);
+                       *cp++ = (unsigned char)((ldigit >>= 8) & 0xFF);
+                       *cp++ = (unsigned char)((ldigit >>= 8) & 0xFF);
+               }
        }
 
        while (strobjp->ob_size && !*--cp)
@@ -1584,7 +1590,7 @@ static PyNumberMethods mpz_as_number = {
 };
 
 static PyTypeObject MPZtype = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,                      /*ob_size*/
        "mpz",                  /*tp_name*/
        sizeof(mpzobject),      /*tp_size*/
@@ -1716,6 +1722,7 @@ initmpz(void)
 #endif /* def MPZ_DEBUG */
 
        mp_set_memory_functions( mp_allocate, mp_reallocate, mp_free );
+        MPZtype.ob_type = &PyType_Type;
        module = Py_InitModule("mpz", mpz_functions);
 
        /* create some frequently used constants */