mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
The new {b,l}p_{u,}longlong() didn't check get_pylong()'s return for NULL.
Repaired that, and added appropriate tests for it to test_struct.py.
This commit is contained in:
parent
d1a7da6c0d
commit
da9c5b35a3
2 changed files with 14 additions and 0 deletions
|
|
@ -314,4 +314,10 @@ def test_std_qQ():
|
||||||
pass
|
pass
|
||||||
test_one_qQ(x)
|
test_one_qQ(x)
|
||||||
|
|
||||||
|
# Some error cases.
|
||||||
|
for direction in "<>":
|
||||||
|
for letter in "qQ":
|
||||||
|
for badobject in "a string", 3+42j, randrange:
|
||||||
|
any_err(struct.pack, direction + letter, badobject)
|
||||||
|
|
||||||
test_std_qQ()
|
test_std_qQ()
|
||||||
|
|
|
||||||
|
|
@ -874,6 +874,8 @@ bp_longlong(char *p, PyObject *v, const formatdef *f)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
v = get_pylong(v);
|
v = get_pylong(v);
|
||||||
|
if (v == NULL)
|
||||||
|
return -1;
|
||||||
res = _PyLong_AsByteArray((PyLongObject *)v,
|
res = _PyLong_AsByteArray((PyLongObject *)v,
|
||||||
(unsigned char *)p,
|
(unsigned char *)p,
|
||||||
8,
|
8,
|
||||||
|
|
@ -888,6 +890,8 @@ bp_ulonglong(char *p, PyObject *v, const formatdef *f)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
v = get_pylong(v);
|
v = get_pylong(v);
|
||||||
|
if (v == NULL)
|
||||||
|
return -1;
|
||||||
res = _PyLong_AsByteArray((PyLongObject *)v,
|
res = _PyLong_AsByteArray((PyLongObject *)v,
|
||||||
(unsigned char *)p,
|
(unsigned char *)p,
|
||||||
8,
|
8,
|
||||||
|
|
@ -1036,6 +1040,8 @@ lp_longlong(char *p, PyObject *v, const formatdef *f)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
v = get_pylong(v);
|
v = get_pylong(v);
|
||||||
|
if (v == NULL)
|
||||||
|
return -1;
|
||||||
res = _PyLong_AsByteArray((PyLongObject*)v,
|
res = _PyLong_AsByteArray((PyLongObject*)v,
|
||||||
(unsigned char *)p,
|
(unsigned char *)p,
|
||||||
8,
|
8,
|
||||||
|
|
@ -1050,6 +1056,8 @@ lp_ulonglong(char *p, PyObject *v, const formatdef *f)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
v = get_pylong(v);
|
v = get_pylong(v);
|
||||||
|
if (v == NULL)
|
||||||
|
return -1;
|
||||||
res = _PyLong_AsByteArray((PyLongObject*)v,
|
res = _PyLong_AsByteArray((PyLongObject*)v,
|
||||||
(unsigned char *)p,
|
(unsigned char *)p,
|
||||||
8,
|
8,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue