Commit ee3e424
committed
Handle exceptions in numpy::array_view<...>::set().
set() can throw an exception; we must check for that to properly get
that exception propagated to the python side; otherwise we get a
SystemError ("method ... returned a result with an exception set").
Example repro:
```
from pylab import *
gca().add_collection(mpl.collections.LineCollection(rand(2, 2, 2), array=0))
```
(Here the C extension method receives a single tuple (rgba) color rather
than an array of tuple (rgba) colors.)
I'd rather not explicitly test for the exception being raised (a
ValueError) because if switching to pybind11 one naturally gets a
broadcast of the scalar value into a correctly dimensionalized array;
indeed mplcairo handles the above example just fine.1 parent efd66d4 commit ee3e424
1 file changed
+8
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
513 | | - | |
514 | | - | |
| 513 | + | |
| 514 | + | |
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
| |||
523 | 523 | | |
524 | 524 | | |
525 | 525 | | |
526 | | - | |
527 | | - | |
| 526 | + | |
| 527 | + | |
528 | 528 | | |
529 | 529 | | |
530 | 530 | | |
| |||
536 | 536 | | |
537 | 537 | | |
538 | 538 | | |
539 | | - | |
540 | | - | |
| 539 | + | |
| 540 | + | |
541 | 541 | | |
542 | 542 | | |
543 | 543 | | |
| |||
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
552 | | - | |
553 | | - | |
| 552 | + | |
| 553 | + | |
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
| |||
0 commit comments