Pass a surface instance instead of a filename to a Plot class causes errors

Bug #293927 reported by Luiz Fernando Barbosa Vital
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cairo Plot
New
Undecided
Rodrigo Moreira Araújo

Bug Description

I was trying to get data generated from Plot classes to a StringIO object instead of a file, so I passed a Cairo surface instance to the Plot class for later access to the surface methods wanted.

{{{

data = [3,1,10,2]
width, height = 300, 300
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
CairoPlot.bar_plot(surface, data, width, height, border = 20, grid = True, rounded_corners = True)

resp = StringIO()
surface.write_to_png(resp)

}}}

That raised 2 errors:
 * one complaining about endswith called with None (the value of self.filename in the class)
 * and the other of calling write_to_png on a finished surface.

I'm attaching a quick and dirty fix for this.

Probably a better approach to solve this problem is to accept file-like objects as argument in addition to strings and surface instances.

Revision history for this message
Luiz Fernando Barbosa Vital (luiz-vital) wrote :
description: updated
Changed in cairoplot:
assignee: nobody → alf-rodrigo
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.