summaryrefslogtreecommitdiffstats
path: root/Modules/structmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-06-29 04:00:40 (GMT)
committerGuido van Rossum <guido@python.org>1998-06-29 04:00:40 (GMT)
commit39ef2274a39cbae96b1335969f84da9a9adadc27 (patch)
tree8ea3a63843c0faccfac186cba441a153e5766b50 /Modules/structmodule.c
parentc94f16f15669faf494a99961334ebbaac88c54d9 (diff)
downloadcpython-39ef2274a39cbae96b1335969f84da9a9adadc27.zip
cpython-39ef2274a39cbae96b1335969f84da9a9adadc27.tar.gz
cpython-39ef2274a39cbae96b1335969f84da9a9adadc27.tar.bz2
Unsigned 1 and 2 byte sized formats shouldn't result in long integer values!
Diffstat (limited to 'Modules/structmodule.c')
-rw-r--r--Modules/structmodule.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/structmodule.c b/Modules/structmodule.c
index d837e02..af8f1e5 100644
--- a/Modules/structmodule.c
+++ b/Modules/structmodule.c
@@ -694,7 +694,10 @@ bu_uint(p, f)
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 @@ lu_uint(p, f)
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 *