diff -r 5e12ad3013ff Lib/test/test_csv.py --- a/Lib/test/test_csv.py Mon Aug 27 19:50:36 2012 +0100 +++ b/Lib/test/test_csv.py Fri Aug 31 19:53:02 2012 +0200 @@ -207,7 +207,6 @@ fileobj.close() os.unlink(name) - @unittest.skipIf(test_support.is_jython, "FIXME: not working in Jython") def test_write_float(self): # Issue 13573: loss of precision because csv.writer # uses str() for floats instead of repr() @@ -603,10 +602,9 @@ ### "long" means the row is longer than the number of fieldnames ### "short" means there are fewer elements in the row than fieldnames - @unittest.skipIf(test_support.is_jython, "FIXME: not working in Jython") def test_write_simple_dict(self): fd, name = tempfile.mkstemp() - fileobj = io.open(fd, 'w+b') + fileobj = os.fdopen(fd, 'w+b') try: writer = csv.DictWriter(fileobj, fieldnames = ["f1", "f2", "f3"]) writer.writeheader() @@ -790,7 +788,6 @@ fileobj.close() os.unlink(name) - @unittest.skipIf(test_support.is_jython, "FIXME: not working in Jython") def test_double_write(self): import array contents = [(20-i)*0.1 for i in range(20)] @@ -807,7 +804,6 @@ fileobj.close() os.unlink(name) - @unittest.skipIf(test_support.is_jython, "FIXME: not working in Jython") def test_float_write(self): import array contents = [(20-i)*0.1 for i in range(20)] diff -r 5e12ad3013ff src/org/python/modules/_csv/PyWriter.java --- a/src/org/python/modules/_csv/PyWriter.java Mon Aug 27 19:50:36 2012 +0100 +++ b/src/org/python/modules/_csv/PyWriter.java Fri Aug 31 19:53:02 2012 +0200 @@ -1,8 +1,11 @@ /* Copyright (c) Jython Developers */ package org.python.modules._csv; +import java.util.ArrayList; + import org.python.core.Py; import org.python.core.PyException; +import org.python.core.PyFloat; import org.python.core.PyObject; import org.python.core.PyString; import org.python.core.PyType; @@ -38,6 +41,13 @@ /** Whether field should be quoted during a join. */ private boolean quoted = false; + + /** The list of classes that must use __repr__ for serialization */ + private ArrayList> reprTypes = new ArrayList>(); + { + // instance initializer + reprTypes.add(PyFloat.class); + } public PyWriter(PyObject writeline, PyDialect dialect) { this.writeline = writeline; @@ -130,7 +140,13 @@ } else if (field == Py.None) { append_ok = join_append("", len == 1); } else { - PyObject str = field.__str__(); + + PyObject str; + if (reprTypes.contains(field.getClass())) + str = field.__repr__(); + else + str = field.__str__(); + if (str == null) { return false; }