]> granicus.if.org Git - python/commitdiff
fix a struct regression where long would be returned for short unsigned integers
authorBob Ippolito <bob@redivi.com>
Thu, 25 May 2006 19:15:27 +0000 (19:15 +0000)
committerBob Ippolito <bob@redivi.com>
Thu, 25 May 2006 19:15:27 +0000 (19:15 +0000)
Modules/_struct.c

index ec896bf24dc08cf5a13a3613b721f2eb1482b4a6..1c885b7430da19b8a09678d6b955e96cbb665db7 100644 (file)
@@ -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);
 }