summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
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);
}