From: <pj...@us...> - 2009-08-16 23:14:40
|
Revision: 6683 http://jython.svn.sourceforge.net/jython/?rev=6683&view=rev Author: pjenvey Date: 2009-08-16 22:40:47 +0000 (Sun, 16 Aug 2009) Log Message: ----------- restrict array writes to binary mode Modified Paths: -------------- trunk/jython/src/org/python/core/PyFile.java Modified: trunk/jython/src/org/python/core/PyFile.java =================================================================== --- trunk/jython/src/org/python/core/PyFile.java 2009-08-16 22:25:58 UTC (rev 6682) +++ trunk/jython/src/org/python/core/PyFile.java 2009-08-16 22:40:47 UTC (rev 6683) @@ -354,12 +354,12 @@ file_write(o.__str__().string); } else if (o instanceof PyString) { file_write(((PyString)o).string); - } else if (o instanceof PyArray) { - ((PyArray)o).tofile(this); + } else if (binary && o instanceof PyArray) { + file_write(((PyArray)o).tostring()); } else { - //XXX: Match CPython's error message better - // "argument 1 must be string or read-only buffer, not {type}" - throw Py.TypeError("write requires a string or read-only buffer as its argument"); + throw Py.TypeError(String.format("argument 1 must be string or %sbuffer, not %.200s", + binary ? "" : "read-only character ", + o.getType().fastGetName())); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |