fix a struct regression where long would be returned for short unsigned integers

This commit is contained in:
Bob Ippolito 2006-05-25 19:15:27 +00:00
parent 3fc2bb9ccd
commit 3b0cae9cc0

View 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);
}