Author: Maciej Fijalkowski <[email protected]>
Branch: rdict-experiments-3
Changeset: r67572:892b8d15b53f
Date: 2013-10-24 15:35 +0200
http://bitbucket.org/pypy/pypy/changeset/892b8d15b53f/

Log:    Shuffle setup around until it works

diff --git a/rpython/rtyper/lltypesystem/rdict.py 
b/rpython/rtyper/lltypesystem/rdict.py
--- a/rpython/rtyper/lltypesystem/rdict.py
+++ b/rpython/rtyper/lltypesystem/rdict.py
@@ -183,6 +183,7 @@
     def __init__(self, rtyper, key_repr, value_repr, dictkey, dictvalue,
                  custom_eq_hash=None):
         self.rtyper = rtyper
+        self.finalized = False
         self.DICT = lltype.GcForwardReference()
         self.lowleveltype = lltype.Ptr(self.DICT)
         self.custom_eq_hash = custom_eq_hash is not None
@@ -237,10 +238,12 @@
                         rtyper=self.rtyper, **kwd)
 
     def _setup_repr_final(self):
-        LOOKUP_FUNC = self.lowleveltype.TO.lookup_function
-        family = self.lowleveltype.TO.lookup_family
-        _setup_lookup_funcs(LOOKUP_FUNC, self.lowleveltype.TO, self.rtyper,
-                            family)
+        if not self.finalized:
+            LOOKUP_FUNC = self.lowleveltype.TO.lookup_function
+            family = self.lowleveltype.TO.lookup_family
+            _setup_lookup_funcs(LOOKUP_FUNC, self.lowleveltype.TO, self.rtyper,
+                                family)
+            self.finalized = True
 
 
     def convert_const(self, dictobj):
@@ -256,6 +259,7 @@
             return self.dict_cache[key]
         except KeyError:
             self.setup()
+            self.setup_final()
             l_dict = ll_newdict_size(self.DICT, len(dictobj))
             self.dict_cache[key] = l_dict
             r_key = self.key_repr
diff --git a/rpython/rtyper/rmodel.py b/rpython/rtyper/rmodel.py
--- a/rpython/rtyper/rmodel.py
+++ b/rpython/rtyper/rmodel.py
@@ -53,7 +53,7 @@
         self._initialized = setupstate.INPROGRESS
         try:
             self._setup_repr()
-        except TyperError, e:
+        except TyperError:
             self._initialized = setupstate.BROKEN
             raise
         else:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to