Unsigned 1 and 2 byte sized formats shouldn't result in long integer values!

This commit is contained in:
Guido van Rossum 1998-06-29 04:00:40 +00:00
parent c94f16f156
commit 39ef2274a3
1 changed files with 8 additions and 2 deletions

View File

@ -694,7 +694,10 @@ bu_uint(p, f)
do { do {
x = (x<<8) | (*p++ & 0xFF); x = (x<<8) | (*p++ & 0xFF);
} while (--i > 0); } while (--i > 0);
return PyLong_FromUnsignedLong(x); if (f->size >= 4)
return PyLong_FromUnsignedLong(x);
else
return PyInt_FromLong((long)x);
} }
static PyObject * static PyObject *
@ -825,7 +828,10 @@ lu_uint(p, f)
do { do {
x = (x<<8) | (p[--i] & 0xFF); x = (x<<8) | (p[--i] & 0xFF);
} while (i > 0); } while (i > 0);
return PyLong_FromUnsignedLong(x); if (f->size >= 4)
return PyLong_FromUnsignedLong(x);
else
return PyInt_FromLong((long)x);
} }
static PyObject * static PyObject *