[pypy-svn] r13543 - pypy/dist/pypy/translator/pickle

pedronis at codespeak.net pedronis at codespeak.net
Fri Jun 17 17:51:28 CEST 2005


Author: pedronis
Date: Fri Jun 17 17:51:27 2005
New Revision: 13543

Modified:
   pypy/dist/pypy/translator/pickle/genpickle.py
Log:
fixing pickling of OVERFLOwDED_FLOAT



Modified: pypy/dist/pypy/translator/pickle/genpickle.py
==============================================================================
--- pypy/dist/pypy/translator/pickle/genpickle.py	(original)
+++ pypy/dist/pypy/translator/pickle/genpickle.py	Fri Jun 17 17:51:27 2005
@@ -38,6 +38,9 @@
 # ____________________________________________________________
 
 
+#XXX Hack: This float is supposed to overflow to inf
+OVERFLOWED_FLOAT = float("1e10000000000000000000000000000000")
+
 class GenPickle:
 
     def __init__(self, translator, writer = None):
@@ -50,8 +53,6 @@
             'import new, types, sys',
             )
         self.picklenames = {}  # memoize objects
-        self.memoize(float("1e10000000000000000000000000000000"),
-                     'float("1e10000000000000000000000000000000")')
         for name in all_feature_names + "new types sys".split():
             self.memoize(globals()[name], name)
         self.namespace = NameManager()
@@ -64,7 +65,7 @@
         self.simple_const_types = {
             int: repr,
             long: repr,
-            float: repr,
+            float: self.save_float,
             str: repr,
             unicode: repr,
             type(None): repr,
@@ -102,6 +103,11 @@
             SpaceOperation: True,
             }
 
+    def save_float(self, fl):
+        if fl == OVERFLOWED_FLOAT:
+            return 'float("1e10000000000000000000000000000000")'
+        return repr(fl)
+
     def pickle(self, **kwds):
         for obj in kwds.values():
             self.nameof(obj)



More information about the Pypy-commit mailing list