mirror of
https://github.com/python/cpython.git
synced 2025-10-01 04:42:10 +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");
|
"ubyte format requires 0 <= number <= 255");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*p = (char)x;
|
*(unsigned char *)p = (unsigned char)x;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -868,6 +868,7 @@ bp_int(char *p, PyObject *v, const formatdef *f)
|
||||||
{
|
{
|
||||||
long x;
|
long x;
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
|
unsigned char *q = (unsigned char *)p;
|
||||||
if (get_long(v, &x) < 0)
|
if (get_long(v, &x) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
i = f->size;
|
i = f->size;
|
||||||
|
@ -880,7 +881,7 @@ bp_int(char *p, PyObject *v, const formatdef *f)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
p[--i] = (char)x;
|
q[--i] = (unsigned char)(x & 0xffL);
|
||||||
x >>= 8;
|
x >>= 8;
|
||||||
} while (i > 0);
|
} while (i > 0);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -891,6 +892,7 @@ bp_uint(char *p, PyObject *v, const formatdef *f)
|
||||||
{
|
{
|
||||||
unsigned long x;
|
unsigned long x;
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
|
unsigned char *q = (unsigned char *)p;
|
||||||
if (get_ulong(v, &x) < 0)
|
if (get_ulong(v, &x) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
i = f->size;
|
i = f->size;
|
||||||
|
@ -901,7 +903,7 @@ bp_uint(char *p, PyObject *v, const formatdef *f)
|
||||||
RANGE_ERROR(x, f, 1, maxint - 1);
|
RANGE_ERROR(x, f, 1, maxint - 1);
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
p[--i] = (char)x;
|
q[--i] = (unsigned char)(x & 0xffUL);
|
||||||
x >>= 8;
|
x >>= 8;
|
||||||
} while (i > 0);
|
} while (i > 0);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1087,6 +1089,7 @@ lp_int(char *p, PyObject *v, const formatdef *f)
|
||||||
{
|
{
|
||||||
long x;
|
long x;
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
|
unsigned char *q = (unsigned char *)p;
|
||||||
if (get_long(v, &x) < 0)
|
if (get_long(v, &x) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
i = f->size;
|
i = f->size;
|
||||||
|
@ -1099,7 +1102,7 @@ lp_int(char *p, PyObject *v, const formatdef *f)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
*p++ = (char)x;
|
*q++ = (unsigned char)(x & 0xffL);
|
||||||
x >>= 8;
|
x >>= 8;
|
||||||
} while (--i > 0);
|
} while (--i > 0);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1110,6 +1113,7 @@ lp_uint(char *p, PyObject *v, const formatdef *f)
|
||||||
{
|
{
|
||||||
unsigned long x;
|
unsigned long x;
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
|
unsigned char *q = (unsigned char *)p;
|
||||||
if (get_ulong(v, &x) < 0)
|
if (get_ulong(v, &x) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
i = f->size;
|
i = f->size;
|
||||||
|
@ -1120,7 +1124,7 @@ lp_uint(char *p, PyObject *v, const formatdef *f)
|
||||||
RANGE_ERROR(x, f, 1, maxint - 1);
|
RANGE_ERROR(x, f, 1, maxint - 1);
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
*p++ = (char)x;
|
*q++ = (unsigned char)(x & 0xffUL);
|
||||||
x >>= 8;
|
x >>= 8;
|
||||||
} while (--i > 0);
|
} while (--i > 0);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue