Ticket #3510 (closed defect: fixed)

Opened 14 months ago

Last modified 13 months ago

TA save png failed os8 xo-1.75

Reported by: tonyforster Owned by: walter
Priority: Unspecified by Maintainer Milestone: Unspecified by Release Team
Component: Turtleart Version: Unspecified
Severity: Unspecified Keywords:
Cc: Distribution/OS: Unspecified
Bug Status: Unconfirmed

Description

Traceback (most recent call last):

File "/home/olpc/Activities/TurtleArt.activity/TurtleArt/talogo.py", line 482, in doevalstep

self.step.next()

File "/home/olpc/Activities/TurtleArt.activity/TurtleArt/talogo.py", line 461, in _evalsym

result = self.cfun.fcn(self, *self.arglist)

File "/home/olpc/Activities/TurtleArt.activity/plugins/turtle_blocks_extras/turtle_blocks_extras.py", line 238, in <lambda>

lambda self, x: primitive_dictionarysavepix?(x))

File "/home/olpc/Activities/TurtleArt.activity/plugins/turtle_blocks_extras/turtle_blocks_extras.py", line 1099, in _prim_save_picture

self.tw.save_as_image(name)

File "/home/olpc/Activities/TurtleArt.activity/TurtleArt/tawindow.py", line 3258, in save_as_image

save_picture(self.canvas, file_path)

File "/home/olpc/Activities/TurtleArt.activity/TurtleArt/tautils.py", line 277, in save_picture

img_surface.write_to_png(file_name)

TypeError: Surface.write_to_png takes one argument which must be a filename (str), file object, or a file-like object which has a "write" method (like StringIO)

Attachments

png fail.ta Download (5.0 KB) - added by tonyforster 14 months ago.
Image clipping type text.png Download (10.1 KB) - added by tonyforster 13 months ago.

Change History

Changed 14 months ago by tonyforster

Changed 14 months ago by tonyforster

  • owner set to walter
  • component changed from untriaged to Turtleart

Changed 14 months ago by walter

This is a bit strange. The error is triggered because somehow the string you are using for the file name is type unicode instead of type string. Not sure how that could have happened. I'll add a conversion in these cases, but will also try to find the root cause, i.e., where the unicode conversion is happening.

if type(file_name) == unicode:

img_surface.write_to_png(str(file_name.encode('ascii', 'replace')))

else:

img_surface.write_to_png(str(file_name))

Changed 13 months ago by walter

  • status changed from new to closed
  • resolution set to fixed

fixed in v139, although the root cause is still somewhat of a mystery.

Changed 13 months ago by tonyforster

works ok in v139

FWIW green text boxes are all type unicode and purple number boxes are all type float

Changed 13 months ago by tonyforster

I wasn't quite right there, the text block on the pallette is type string but it becomes type unicode when edited

Changed 13 months ago by tonyforster

Note: See TracTickets for help on using tickets.