mirror of
https://github.com/python/cpython.git
synced 2025-09-14 04:37:29 +00:00
fix a struct regression where long would be returned for short unsigned integers
This commit is contained in:
parent
3fc2bb9ccd
commit
3b0cae9cc0
1 changed files with 6 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue