From: Bob Ippolito Date: Thu, 25 May 2006 19:15:27 +0000 (+0000) Subject: fix a struct regression where long would be returned for short unsigned integers X-Git-Tag: v2.5b1~521 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3b0cae9cc06374eb7a7159f1328ec700208d6109;p=thirdparty%2FPython%2Fcpython.git fix a struct regression where long would be returned for short unsigned integers --- diff --git a/Modules/_struct.c b/Modules/_struct.c index ec896bf24dc0..1c885b7430da 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -609,6 +609,9 @@ bu_uint(const char *p, const formatdef *f) #ifdef PY_USE_INT_WHEN_POSSIBLE if (x <= INT_MAX) return PyInt_FromLong((long)x); +#else + if (SIZEOF_LONG > f->size) + return PyInt_FromLong((long)x); #endif return PyLong_FromUnsignedLong(x); } @@ -805,6 +808,9 @@ lu_uint(const char *p, const formatdef *f) #ifdef PY_USE_INT_WHEN_POSSIBLE if (x <= INT_MAX) return PyInt_FromLong((long)x); +#else + if (SIZEOF_LONG > f->size) + return PyInt_FromLong((long)x); #endif return PyLong_FromUnsignedLong((long)x); }