diff Modules/structmodule.c @ 8580:1ca6895024d9 legacy-trunk

Unsigned 1 and 2 byte sized formats shouldn't result in long integer values!
author Guido van Rossum <guido@python.org>
date Mon, 29 Jun 1998 04:00:40 +0000
parents ae746eab2a96
children 17d0c51e0887
line wrap: on
line diff
--- a/Modules/structmodule.c	Mon Jun 29 00:42:54 1998 +0000
+++ b/Modules/structmodule.c	Mon Jun 29 04:00:40 1998 +0000
@@ -694,7 +694,10 @@
 	do {
 		x = (x<<8) | (*p++ & 0xFF);
 	} while (--i > 0);
-	return PyLong_FromUnsignedLong(x);
+	if (f->size >= 4)
+		return PyLong_FromUnsignedLong(x);
+	else
+		return PyInt_FromLong((long)x);
 }
 
 static PyObject *
@@ -825,7 +828,10 @@
 	do {
 		x = (x<<8) | (p[--i] & 0xFF);
 	} while (i > 0);
-	return PyLong_FromUnsignedLong(x);
+	if (f->size >= 4)
+		return PyLong_FromUnsignedLong(x);
+	else
+		return PyInt_FromLong((long)x);
 }
 
 static PyObject *