id summary reporter owner description type status priority milestone component resolution keywords cc merged author reviewer upstream work_issues branch commit dependencies stopgaps
11577 save(x,filename) fails for pure Python objects for x if filename contains a dot logix ncalexan "(The summary actually is not completely accurate - there might be some Python object this works for that I'm not aware of)
If the filename passed to save() contains a dot, save() assumes that the user doesnt just want to dump the (pickled) object, but instead wants to call the object's save() method. I guess this makes sense in situations like save(g, 'mygraph.png'), but the code should fall back to dumping the pickled version (e.g. via try: ... except AttributeError: ... - suggested via IRC by leif) if the object has no save() method.
leif also suggested checking if the file name extension is known - however I guess that we then should verify this with the object itself (e.g. it wouldn't make sense to save a graphics object to a .wav file) and not statically compare with a list of known extensions.
{{{
sage: save((1,1), 'foo2')
sage: save(Matrix(3,3), 'foo.bar3')
sage: save((1,1), 'foo.bar4')
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/tmp/sagedebug/ in ()
/usr/local/sage/local/lib/python2.6/site-packages/sage/structure/sage_object.so in sage.structure.sage_object.save (sage/structure/sage_object.c:8156)()
AttributeError: 'tuple' object has no attribute 'save'
}}}
" defect new minor sage-4.7.2 sage-mode N/A