[pypy-svn] r32694 - in pypy/dist/pypy/objspace/cclp: . constraint

auc at codespeak.net auc at codespeak.net
Thu Sep 28 16:36:31 CEST 2006


Author: auc
Date: Thu Sep 28 16:36:28 2006
New Revision: 32694

Modified:
   pypy/dist/pypy/objspace/cclp/constraint/distributor.py
   pypy/dist/pypy/objspace/cclp/scheduler.py
   pypy/dist/pypy/objspace/cclp/space.py
   pypy/dist/pypy/objspace/cclp/thunk.py
Log:
another round of transl. fixes (translating logic objspace with backend opts should trigger the failed assert of 
"../translator/backendopt/inline.py", triggered line 505, in measure_median_execution_cost)


Modified: pypy/dist/pypy/objspace/cclp/constraint/distributor.py
==============================================================================
--- pypy/dist/pypy/objspace/cclp/constraint/distributor.py	(original)
+++ pypy/dist/pypy/objspace/cclp/constraint/distributor.py	Thu Sep 28 16:36:28 2006
@@ -138,7 +138,12 @@
         nb_elts = max(subdoms, len(values))  / float(subdoms)
         start, end = (int(math.floor(choice * nb_elts)),
                       int(math.floor((choice + 1) * nb_elts)))
+        lv = len(values)
+        assert start >= 0
+        assert start <= lv
         domain.remove_values(values[:start])
+        assert end >= 0
+        assert end <= lv
         domain.remove_values(values[end:])
 
 def make_split_distributor(space, w_fanout):

Modified: pypy/dist/pypy/objspace/cclp/scheduler.py
==============================================================================
--- pypy/dist/pypy/objspace/cclp/scheduler.py	(original)
+++ pypy/dist/pypy/objspace/cclp/scheduler.py	Thu Sep 28 16:36:28 2006
@@ -51,7 +51,7 @@
             assert self._head not in self._blocked_on
             assert self._head not in self._blocked_byneed
             assert self._head not in self._asking
-        except:
+        except Exception:
             #XXX give sched_info maybe
             raise OperationError(self.space.w_RuntimeError,
                                  self.space.wrap("scheduler is in an incoherent state"))

Modified: pypy/dist/pypy/objspace/cclp/space.py
==============================================================================
--- pypy/dist/pypy/objspace/cclp/space.py	(original)
+++ pypy/dist/pypy/objspace/cclp/space.py	Thu Sep 28 16:36:28 2006
@@ -35,7 +35,7 @@
     assert isinstance(w_n, W_IntObject)
     n = space.int_w(w_n)
     cspace = get_current_cspace(space)
-    if cspace != None:
+    if cspace is not None:
         assert isinstance(cspace, W_CSpace)
         try:
             return cspace.choose(w_n.intval)

Modified: pypy/dist/pypy/objspace/cclp/thunk.py
==============================================================================
--- pypy/dist/pypy/objspace/cclp/thunk.py	(original)
+++ pypy/dist/pypy/objspace/cclp/thunk.py	Thu Sep 28 16:36:28 2006
@@ -167,6 +167,10 @@
                 while dist.distributable():
                     choice = cspace.choose(dist.fanout())
                     dist.w_distribute(choice)
+            except ConsistencyError, e:
+                w("-- DISTRIBUTOR thunk exited because", str(e))
+                interp_bind(cspace._choice, self.space.newint(0))
+            else:
                 w("-- DISTRIBUTOR thunk exited because a solution was found")
                 #XXX assert that all propagators are entailed
                 sol = cspace._solution
@@ -181,13 +185,6 @@
                     interp_bind(var, dom.get_values()[0])
                 assert interp_free(cspace._choice)
                 interp_bind(cspace._choice, self.space.newint(1))
-            except ConsistencyError, e:
-                w("-- DISTRIBUTOR thunk exited because", str(e))
-                interp_bind(cspace._choice, self.space.newint(0))
-            except:
-                if not we_are_translated():
-                    import traceback
-                    traceback.print_exc()
         finally:
             interp_bind(cspace._finished, self.space.w_True)
             coro._dead = True



More information about the Pypy-commit mailing list