mirror of
https://github.com/python/cpython.git
synced 2025-08-19 00:00:48 +00:00
SF #1693079 Array module cannot pickle empty arrays
This commit is contained in:
parent
93e9384402
commit
4bbcb64d5d
3 changed files with 30 additions and 6 deletions
|
@ -1147,12 +1147,19 @@ array_reduce(arrayobject *array)
|
|||
dict = Py_None;
|
||||
Py_INCREF(dict);
|
||||
}
|
||||
result = Py_BuildValue("O(cs#)O",
|
||||
array->ob_type,
|
||||
array->ob_descr->typecode,
|
||||
array->ob_item,
|
||||
array->ob_size * array->ob_descr->itemsize,
|
||||
dict);
|
||||
if (array->ob_size > 0) {
|
||||
result = Py_BuildValue("O(cs#)O",
|
||||
array->ob_type,
|
||||
array->ob_descr->typecode,
|
||||
array->ob_item,
|
||||
array->ob_size * array->ob_descr->itemsize,
|
||||
dict);
|
||||
} else {
|
||||
result = Py_BuildValue("O(c)O",
|
||||
array->ob_type,
|
||||
array->ob_descr->typecode,
|
||||
dict);
|
||||
}
|
||||
Py_DECREF(dict);
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue