[Python-checkins] r46243 - python/trunk/Modules/_struct.c

bob.ippolito python-checkins at python.org
Thu May 25 21:15:28 CEST 2006


Author: bob.ippolito
Date: Thu May 25 21:15:27 2006
New Revision: 46243

Modified:
   python/trunk/Modules/_struct.c
Log:
fix a struct regression where long would be returned for short unsigned integers

Modified: python/trunk/Modules/_struct.c
==============================================================================
--- python/trunk/Modules/_struct.c	(original)
+++ python/trunk/Modules/_struct.c	Thu May 25 21:15:27 2006
@@ -609,6 +609,9 @@
 #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 @@
 #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);
 }


More information about the Python-checkins mailing list