Commit 66f4fdf
authored
BUG: fix incorrect alignment handling and error handling in several code paths (numpy#31615)
Fixes two error paths that are trivially incorrect for OOM scenarios:
arr_place uses PyArray_ResolveWritebackIfCopy in an error path, but it probably makes more sense to use PyArray_DiscardWritebackIfCopy, as suggested in the docstring for that function: https://numpy.org/doc/2.4/reference/c-api/array.html#c.PyArray_DiscardWritebackIfCopy
PyArray_PutTo and PyArray_PutMask fail to check if PyArray_FromArray fails.
Fixes an incorrect assumption in the flatiter assignment code - the result array might be a user-supplied unaligned array.
Fixes a logic error in boolean indexing, where if an error is raised during an iteration, the iteration is not halted and it's possible the error could be silently discarded.
Adds tests for the latter two cases.1 parent ce6dd7d commit 66f4fdf
6 files changed
Lines changed: 42 additions & 5 deletions
File tree
- numpy/_core
- src/multiarray
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
417 | | - | |
| 417 | + | |
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
442 | 445 | | |
443 | 446 | | |
444 | 447 | | |
| |||
732 | 735 | | |
733 | 736 | | |
734 | 737 | | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
735 | 741 | | |
736 | 742 | | |
737 | 743 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
849 | 849 | | |
850 | 850 | | |
851 | 851 | | |
852 | | - | |
853 | | - | |
| 852 | + | |
| 853 | + | |
854 | 854 | | |
855 | 855 | | |
856 | 856 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1076 | 1076 | | |
1077 | 1077 | | |
1078 | 1078 | | |
1079 | | - | |
| 1079 | + | |
1080 | 1080 | | |
1081 | 1081 | | |
1082 | 1082 | | |
| |||
1274 | 1274 | | |
1275 | 1275 | | |
1276 | 1276 | | |
1277 | | - | |
| 1277 | + | |
1278 | 1278 | | |
1279 | 1279 | | |
1280 | 1280 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1365 | 1365 | | |
1366 | 1366 | | |
1367 | 1367 | | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
1368 | 1384 | | |
1369 | 1385 | | |
1370 | 1386 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6904 | 6904 | | |
6905 | 6905 | | |
6906 | 6906 | | |
| 6907 | + | |
| 6908 | + | |
| 6909 | + | |
| 6910 | + | |
| 6911 | + | |
| 6912 | + | |
| 6913 | + | |
| 6914 | + | |
| 6915 | + | |
| 6916 | + | |
| 6917 | + | |
| 6918 | + | |
| 6919 | + | |
| 6920 | + | |
| 6921 | + | |
6907 | 6922 | | |
6908 | 6923 | | |
6909 | 6924 | | |
| |||
0 commit comments