diff --git a/test/bytecode_2.7/01_float.pyc b/test/bytecode_2.7/01_float.pyc new file mode 100644 index 00000000..db9f8c70 Binary files /dev/null and b/test/bytecode_2.7/01_float.pyc differ diff --git a/test/simple_source/expression/01_float.py b/test/simple_source/expression/01_float.py new file mode 100644 index 00000000..93a93975 --- /dev/null +++ b/test/simple_source/expression/01_float.py @@ -0,0 +1,4 @@ +a = 1e300 * 1e300 * 0 +b = -1e300 * 1e300 * 0 +c = 1e300 * 1e300 +d = -1e300 * 1e300 diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index ca5202c1..adb292a6 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -808,7 +808,12 @@ class SourceWalker(GenericASTTraversal, object): def n_LOAD_CONST(self, node): data = node.pattr; datatype = type(data) - if isinstance(datatype, int) and data == minint: + if isinstance(data, float) and str(data) in frozenset(['nan', '-nan', 'inf', '-inf']): + # float values 'nan' and 'inf' are not directly representable in Python at least + # before 3.5 and even there it is via a library constant. + # So we will canonicalize their representation as float('nan') and float('inf') + self.write("float('%s')" % data) + elif isinstance(datatype, int) and data == minint: # convert to hex, since decimal representation # would result in 'LOAD_CONST; UNARY_NEGATIVE' # change:hG/2002-02-07: this was done for all negative integers