Potential Bug in `patheffects.py`

Greetings. First time poster, long-time user.

I’m in the process of converting a legacy matplotlib script (v1.3.1 - legacy MacOS version) to v3.5.1. When I send the line plot to savefig, I get the following traceback:

  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/matplotlib/patheffects.py", line 101, in draw_path
    path_effect.draw_path(self._renderer, gc, tpath, affine,
AttributeError: 'str' object has no attribute 'draw_path'

The method in question (from patheffects.py):

    def draw_path(self, gc, tpath, affine, rgbFace=None):
        for path_effect in self._path_effects:
            path_effect.draw_path(self._renderer, gc, tpath, affine,
                                  rgbFace)

I modified the draw_path method to inspect the self._path_effects object; it comes through as ['[]']. Not sure why the ‘path_effect’ object is coming through as a string. I don’t get the error when running the script under v1.3.1.

My guess is that is bug is actually in parsing rcparams, do you have a custom rcparams file, can you check the value of mpl.rcParams['path.effects']?

Failing that, do you call art.set_path_effects anywhere?

Can you extract a (minimal) bit of code to reproduce this?

Also, that is a ~9 year jump! Hopefully we have not broken too much under you.

I do have a custom style involved.

path.effects: []

(which I believe is the default). I don’t reset path.effects anywhere nor call art.set_path_effects at any point within the project.

Yes, 9 years! The reason for the refactor is that it looks like Apple is going to eliminate Python with MacOS 12.3.

Thanks for the help. Cheers!

Change that to

path.effects:

We expects lists in matplotlibrc to be without [ or ] and to be , seperated so we are reading this as "a single element list with the string value '[]'".

Why this changed is a different question…

That makes perfect sense and also points to the fact that this error is pretty much on me. I’m dumping my rcParams to a style sheet in order to migrate to a more static set of styles and doing that by writing them out to a file. This results in lists being written to file in typical Python style. This is obviously easy to handle and–beyond that–rather than write out all the parms, I’m only going to only write out the changes.

Sorry if that was an unnecessary sidetrack. Cheers!