Commit 3b0cae9c authored by Bob Ippolito's avatar Bob Ippolito

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

parent 3fc2bb9c
...@@ -609,6 +609,9 @@ bu_uint(const char *p, const formatdef *f) ...@@ -609,6 +609,9 @@ bu_uint(const char *p, const formatdef *f)
#ifdef PY_USE_INT_WHEN_POSSIBLE #ifdef PY_USE_INT_WHEN_POSSIBLE
if (x <= INT_MAX) if (x <= INT_MAX)
return PyInt_FromLong((long)x); return PyInt_FromLong((long)x);
#else
if (SIZEOF_LONG > f->size)
return PyInt_FromLong((long)x);
#endif #endif
return PyLong_FromUnsignedLong(x); return PyLong_FromUnsignedLong(x);
} }
...@@ -805,6 +808,9 @@ lu_uint(const char *p, const formatdef *f) ...@@ -805,6 +808,9 @@ lu_uint(const char *p, const formatdef *f)
#ifdef PY_USE_INT_WHEN_POSSIBLE #ifdef PY_USE_INT_WHEN_POSSIBLE
if (x <= INT_MAX) if (x <= INT_MAX)
return PyInt_FromLong((long)x); return PyInt_FromLong((long)x);
#else
if (SIZEOF_LONG > f->size)
return PyInt_FromLong((long)x);
#endif #endif
return PyLong_FromUnsignedLong((long)x); return PyLong_FromUnsignedLong((long)x);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment