Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/matplotlib/tests/test_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@


from matplotlib import (
collections, path, pyplot as plt, transforms as mtransforms, rcParams)
collections, path, patheffects, pyplot as plt, transforms as mtransforms,
rcParams)
from matplotlib.backends.backend_agg import RendererAgg
from matplotlib.figure import Figure
from matplotlib.image import imread
Expand Down Expand Up @@ -349,3 +350,11 @@ def test_chunksize_toobig_chunks(chunk_limit_setup):
rcParams['agg.path.chunksize'] = 90_000
with pytest.raises(OverflowError, match='Please reduce'):
ra.draw_path(gc, p, idt)


def test_non_tuple_rgbaface():
# This passes rgbaFace as a ndarray to draw_path.
fig = plt.figure()
fig.add_subplot(projection="3d").scatter(
[0, 1, 2], [0, 1, 2], path_effects=[patheffects.Stroke(linewidth=4)])
fig.canvas.draw()
17 changes: 12 additions & 5 deletions src/py_converters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,21 +191,28 @@ int convert_rect(PyObject *rectobj, void *rectp)
int convert_rgba(PyObject *rgbaobj, void *rgbap)
{
agg::rgba *rgba = (agg::rgba *)rgbap;

PyObject *rgbatuple = NULL;
int success = 1;
if (rgbaobj == NULL || rgbaobj == Py_None) {
rgba->r = 0.0;
rgba->g = 0.0;
rgba->b = 0.0;
rgba->a = 0.0;
} else {
if (!(rgbatuple = PySequence_Tuple(rgbaobj))) {
success = 0;
goto exit;
}
rgba->a = 1.0;
if (!PyArg_ParseTuple(
rgbaobj, "ddd|d:rgba", &(rgba->r), &(rgba->g), &(rgba->b), &(rgba->a))) {
return 0;
rgbatuple, "ddd|d:rgba", &(rgba->r), &(rgba->g), &(rgba->b), &(rgba->a))) {
success = 0;
goto exit;
}
}

return 1;
exit:
Py_XDECREF(rgbatuple);
return success;
}

int convert_dashes(PyObject *dashobj, void *dashesp)
Expand Down