summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
authorBrandt Bucher <brandtbucher@gmail.com>2020-05-21 13:29:34 -0700
committerGitHub <noreply@github.com>2020-05-21 15:29:34 -0500
commit66c756ce333dc40120d4dd77b14517c6819cd410 (patch)
tree1ee334d889641425e2f12f605853f1f67e96cb75 /numpy/lib/function_base.py
parent41e254f96e8d5bd558d2edbf8b198eb4143e8b74 (diff)
downloadnumpy-66c756ce333dc40120d4dd77b14517c6819cd410.tar.gz
BUG: Don't segfault on bad __len__ when assigning. (gh-16327)
When __getitem__ fails, assignment falls back on __iter__, which may not have the same length as __len__, resulting in a segfault. See gh-7264. * BUG: Don't rely on __len__ for safe iteration. Skip __len__ checking entirely, since this has no guarantees of being correct. Instead, first convert to PySequence_Fast and use that length. Also fixes a refleak when creating a tmp array fails. See gh-7264. * TST: Update test for related edge-case. The previous fix more gracefully handles this edge case by skipping the __len__ check. Rather than raising with an unhelpful error message, just create the array with whatever elements C() actually yields. See gh-7264.
Diffstat (limited to 'numpy/lib/function_base.py')
0 files changed, 0 insertions, 0 deletions