summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBob Ippolito <bob@redivi.com>2006-05-25 19:15:27 (GMT)
committerBob Ippolito <bob@redivi.com>2006-05-25 19:15:27 (GMT)
commit3b0cae9cc06374eb7a7159f1328ec700208d6109 (patch)
treef1ffcd5d7c09acbe01030f8fdeb6bac058812a95 /Modules
parent3fc2bb9ccd6dc6b9b354bf31337297b5d3e3b44b (diff)
downloadcpython-3b0cae9cc06374eb7a7159f1328ec700208d6109.zip
cpython-3b0cae9cc06374eb7a7159f1328ec700208d6109.tar.gz
cpython-3b0cae9cc06374eb7a7159f1328ec700208d6109.tar.bz2
fix a struct regression where long would be returned for short unsigned integers
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_struct.c6
1 files changed, 6 insertions, 0 deletions
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);
}