[pypy-svn] pypy default: Allow this file to be imported if 'float' has no '__getformat__',

arigo commits-noreply at bitbucket.org
Sat Mar 26 17:05:39 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r42978:fbc54ca1d7c2
Date: 2011-03-26 16:05 +0000
http://bitbucket.org/pypy/pypy/changeset/fbc54ca1d7c2/

Log:	Allow this file to be imported if 'float' has no '__getformat__', as
	is the case in pypy 1.4.1.

diff --git a/pypy/rlib/rdtoa.py b/pypy/rlib/rdtoa.py
--- a/pypy/rlib/rdtoa.py
+++ b/pypy/rlib/rdtoa.py
@@ -11,21 +11,17 @@
 include_dirs = [cdir]
 
 # set the word endianness based on the host's endianness
+# and the C double's endianness (which should be equal)
+if hasattr(float, '__getformat__'):
+    assert float.__getformat__('double') == 'IEEE, %s-endian' % sys.byteorder
 if sys.byteorder == 'little':
-    source_file = []
+    source_file = ['#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754']
 elif sys.byteorder == 'big':
-    source_file = ['#define WORDS_BIGENDIAN']
+    source_file = ['#define WORDS_BIGENDIAN',
+                   '#define DOUBLE_IS_BIG_ENDIAN_IEEE754']
 else:
     raise AssertionError(sys.byteorder)
 
-# ...and the C double's endianness
-if float.__getformat__('double') == 'IEEE, little-endian':
-    source_file.append('#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754')
-elif float.__getformat__('double') == 'IEEE, big-endian':
-    source_file.append('#define DOUBLE_IS_BIG_ENDIAN_IEEE754')
-else:
-    raise AssertionError(float.__getformat__())
-
 source_file.append('#include "src/dtoa.c"')
 source_file = '\n\n'.join(source_file)
 


More information about the Pypy-commit mailing list