[pypy-commit] pypy stdlib-2.7.3: CPython issue13573: The csv.writer now uses the repr() for floats rather than str(). This allows floats to round-trip without loss of precision.
amauryfa
noreply at buildbot.pypy.org
Tue Jun 12 23:22:31 CEST 2012
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: stdlib-2.7.3
Changeset: r55635:cc74abe554c9
Date: 2012-06-12 23:07 +0200
http://bitbucket.org/pypy/pypy/changeset/cc74abe554c9/
Log: CPython issue13573: The csv.writer now uses the repr() for floats
rather than str(). This allows floats to round-trip without loss of
precision.
diff --git a/lib_pypy/_csv.py b/lib_pypy/_csv.py
--- a/lib_pypy/_csv.py
+++ b/lib_pypy/_csv.py
@@ -504,9 +504,12 @@
quoted = True
if field is None:
- self._join_append("", quoted, rowlen == 1)
+ value = ""
+ elif isinstance(field, float):
+ value = repr(field)
else:
- self._join_append(str(field), quoted, rowlen == 1)
+ value = str(field)
+ self._join_append(value, quoted, rowlen == 1)
# add line terminator
self.rec.append(dialect.lineterminator)
More information about the pypy-commit
mailing list