[Python-Dev] [patch] fpconst for python3

Neal Becker ndbecker2 at gmail.com
Wed Oct 20 02:57:22 CEST 2010


Where should I send this patch?

diff -u fpconst-0.7.2/fpconst.py fpconst-0.7.2.new/fpconst.py
--- fpconst-0.7.2/fpconst.py	2005-02-24 12:42:03.000000000 -0500
+++ fpconst-0.7.2.new/fpconst.py	2010-10-19 20:55:07.407765664 -0400
@@ -40,18 +40,18 @@
 ident = "$Id: fpconst.py,v 1.16 2005/02/24 17:42:03 warnes Exp $"
 
 import struct, operator
+from functools import reduce
 
 # check endianess
-_big_endian = struct.pack('i',1)[0] != '\x01'
-
+_big_endian = struct.pack('i',1)[0] != 1
 # and define appropriate constants
 if(_big_endian): 
-    NaN    = struct.unpack('d', '\x7F\xF8\x00\x00\x00\x00\x00\x00')[0]
-    PosInf = struct.unpack('d', '\x7F\xF0\x00\x00\x00\x00\x00\x00')[0]
+    NaN    = struct.unpack('d', b'\x7F\xF8\x00\x00\x00\x00\x00\x00')[0]
+    PosInf = struct.unpack('d', b'\x7F\xF0\x00\x00\x00\x00\x00\x00')[0]
     NegInf = -PosInf
 else:
-    NaN    = struct.unpack('d', '\x00\x00\x00\x00\x00\x00\xf8\xff')[0]
-    PosInf = struct.unpack('d', '\x00\x00\x00\x00\x00\x00\xf0\x7f')[0]
+    NaN    = struct.unpack('d', b'\x00\x00\x00\x00\x00\x00\xf8\xff')[0]
+    PosInf = struct.unpack('d', b'\x00\x00\x00\x00\x00\x00\xf0\x7f')[0]
     NegInf = -PosInf
 
 def _double_as_bytes(dval):



More information about the Python-Dev mailing list