Skip to content

Commit 634b683

Browse files
committed
Debian Bug#585442: python-matplotlib: crashes when calling axis() after imshow()
This allows the C++ exception raised when Agg rendering complexity is exceeded to percolate up correctly to a Python exception, rather than crashing the interpreter. svn path=/trunk/matplotlib/; revision=8454
1 parent 50f4601 commit 634b683

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

agg24/include/agg_rasterizer_cells_aa.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,15 @@
2929
#ifndef AGG_RASTERIZER_CELLS_AA_INCLUDED
3030
#define AGG_RASTERIZER_CELLS_AA_INCLUDED
3131

32+
#include "CXX/Exception.hxx"
3233
#include <exception>
3334
#include <string.h>
3435
#include <math.h>
3536
#include "agg_math.h"
3637
#include "agg_array.h"
3738

38-
3939
namespace agg
4040
{
41-
4241
//-----------------------------------------------------rasterizer_cells_aa
4342
// An internal class that implements the main rasterization algorithm.
4443
// Used in the rasterizer. Should not be used direcly.
@@ -180,15 +179,19 @@ namespace agg
180179
template<class Cell>
181180
AGG_INLINE void rasterizer_cells_aa<Cell>::add_curr_cell()
182181
{
182+
static Py::Exception e(
183+
Py::OverflowError(
184+
"Agg rendering complexity exceeded. Consider downsampling or decimating your data."));
185+
186+
183187
if(m_curr_cell.area | m_curr_cell.cover)
184188
{
185189
if((m_num_cells & cell_block_mask) == 0)
186190
{
187191
if(m_num_blocks >= cell_block_limit) {
188192
/* If this exception is thrown too often, one can
189193
increase cell_block_limit */
190-
throw "Agg rendering complexity exceeded. "
191-
"Consider downsampling or decimating your data.";
194+
throw e;
192195
}
193196
allocate_block();
194197
}

0 commit comments

Comments
 (0)