[pypy-svn] pypy default: Added sys.float_repr_style.

alex_gaynor commits-noreply at bitbucket.org
Fri Feb 11 18:17:53 CET 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r41822:7d23136597fd
Date: 2011-02-11 12:17 -0500
http://bitbucket.org/pypy/pypy/changeset/7d23136597fd/

Log:	Added sys.float_repr_style.

diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py
--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -79,6 +79,7 @@
 
         'float_info'            : 'system.get_float_info(space)',
         'long_info'             : 'system.get_long_info(space)',
+        'float_repr_style'      : 'system.get_float_repr_style(space)'
         }
 
     if sys.platform == 'win32':

diff --git a/pypy/module/sys/system.py b/pypy/module/sys/system.py
--- a/pypy/module/sys/system.py
+++ b/pypy/module/sys/system.py
@@ -1,6 +1,7 @@
 """Information about the current system."""
 from pypy.interpreter import gateway
 from pypy.rlib import rfloat, rbigint
+from pypy.rlib.rarithmetic import USE_SHORT_FLOAT_REPR
 from pypy.rpython.lltypesystem import rffi
 
 
@@ -56,3 +57,9 @@
     ]
     w_long_info = app.wget(space, "long_info")
     return space.call_function(w_long_info, space.newtuple(info_w))
+
+def get_float_repr_style(space):
+    if USE_SHORT_FLOAT_REPR:
+        return space.wrap("short")
+    else:
+        return space.wrap("legacy")
\ No newline at end of file

diff --git a/pypy/module/sys/test/test_sysmodule.py b/pypy/module/sys/test/test_sysmodule.py
--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -517,3 +517,10 @@
             pass
         sys.settrace(None)
         assert found == ['call', 'line', 'exception', 'return']
+
+    def test_float_repr_style(self):
+        import sys
+
+        # If this ever actually becomes a compilation option this test should
+        # be changed.
+        assert sys.float_repr_style == "short"
\ No newline at end of file


More information about the Pypy-commit mailing list