From 2010399f4162360065ce823b19bd7a94aadf2a8d Mon Sep 17 00:00:00 2001 From: Moshe Zadka Date: Sat, 31 Mar 2001 10:55:47 +0000 Subject: Make mpz's .binary() work on 64 bit platforms Make mpzmodule compile with cygwin --- Misc/NEWS | 3 +++ Modules/mpzmodule.c | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS b/Misc/NEWS index 957d22a..7651974 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -100,6 +100,9 @@ http://sourceforge.net/tracker/index.php?func=detail&aid=&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? ========================= diff --git a/Modules/mpzmodule.c b/Modules/mpzmodule.c index 2cce2cc..7a78299 100644 --- a/Modules/mpzmodule.c +++ b/Modules/mpzmodule.c @@ -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 */ -- cgit v0.12