From 3b0cae9cc06374eb7a7159f1328ec700208d6109 Mon Sep 17 00:00:00 2001 From: Bob Ippolito Date: Thu, 25 May 2006 19:15:27 +0000 Subject: fix a struct regression where long would be returned for short unsigned integers --- Modules/_struct.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/_struct.c b/Modules/_struct.c index ec896bf..1c885b7 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); } -- cgit v0.12