mirror of
https://github.com/python/cpython.git
synced 2025-09-30 12:21:51 +00:00
parent
0ce1f7e02d
commit
aad1caf55f
1 changed files with 9 additions and 5 deletions
|
@ -539,7 +539,7 @@ np_ubyte(char *p, PyObject *v, const formatdef *f)
|
|||
"ubyte format requires 0 <= number <= 255");
|
||||
return -1;
|
||||
}
|
||||
*p = (char)x;
|
||||
*(unsigned char *)p = (unsigned char)x;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -868,6 +868,7 @@ bp_int(char *p, PyObject *v, const formatdef *f)
|
|||
{
|
||||
long x;
|
||||
Py_ssize_t i;
|
||||
unsigned char *q = (unsigned char *)p;
|
||||
if (get_long(v, &x) < 0)
|
||||
return -1;
|
||||
i = f->size;
|
||||
|
@ -880,7 +881,7 @@ bp_int(char *p, PyObject *v, const formatdef *f)
|
|||
#endif
|
||||
}
|
||||
do {
|
||||
p[--i] = (char)x;
|
||||
q[--i] = (unsigned char)(x & 0xffL);
|
||||
x >>= 8;
|
||||
} while (i > 0);
|
||||
return 0;
|
||||
|
@ -891,6 +892,7 @@ bp_uint(char *p, PyObject *v, const formatdef *f)
|
|||
{
|
||||
unsigned long x;
|
||||
Py_ssize_t i;
|
||||
unsigned char *q = (unsigned char *)p;
|
||||
if (get_ulong(v, &x) < 0)
|
||||
return -1;
|
||||
i = f->size;
|
||||
|
@ -901,7 +903,7 @@ bp_uint(char *p, PyObject *v, const formatdef *f)
|
|||
RANGE_ERROR(x, f, 1, maxint - 1);
|
||||
}
|
||||
do {
|
||||
p[--i] = (char)x;
|
||||
q[--i] = (unsigned char)(x & 0xffUL);
|
||||
x >>= 8;
|
||||
} while (i > 0);
|
||||
return 0;
|
||||
|
@ -1087,6 +1089,7 @@ lp_int(char *p, PyObject *v, const formatdef *f)
|
|||
{
|
||||
long x;
|
||||
Py_ssize_t i;
|
||||
unsigned char *q = (unsigned char *)p;
|
||||
if (get_long(v, &x) < 0)
|
||||
return -1;
|
||||
i = f->size;
|
||||
|
@ -1099,7 +1102,7 @@ lp_int(char *p, PyObject *v, const formatdef *f)
|
|||
#endif
|
||||
}
|
||||
do {
|
||||
*p++ = (char)x;
|
||||
*q++ = (unsigned char)(x & 0xffL);
|
||||
x >>= 8;
|
||||
} while (--i > 0);
|
||||
return 0;
|
||||
|
@ -1110,6 +1113,7 @@ lp_uint(char *p, PyObject *v, const formatdef *f)
|
|||
{
|
||||
unsigned long x;
|
||||
Py_ssize_t i;
|
||||
unsigned char *q = (unsigned char *)p;
|
||||
if (get_ulong(v, &x) < 0)
|
||||
return -1;
|
||||
i = f->size;
|
||||
|
@ -1120,7 +1124,7 @@ lp_uint(char *p, PyObject *v, const formatdef *f)
|
|||
RANGE_ERROR(x, f, 1, maxint - 1);
|
||||
}
|
||||
do {
|
||||
*p++ = (char)x;
|
||||
*q++ = (unsigned char)(x & 0xffUL);
|
||||
x >>= 8;
|
||||
} while (--i > 0);
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue