[pypy-svn] r9753 - in pypy/dist/pypy/objspace: . std

hpk at codespeak.net hpk at codespeak.net
Sat Mar 12 22:24:56 CET 2005


Author: hpk
Date: Sat Mar 12 22:24:56 2005
New Revision: 9753

Modified:
   pypy/dist/pypy/objspace/descroperation.py
   pypy/dist/pypy/objspace/std/objspace.py
Log:
substitute the use of space._compare_nesting with 
space.get_ec_state_dict()['...'] ... 

make the space become a SomePBC again (with
the new _freeze_() protocol). 



Modified: pypy/dist/pypy/objspace/descroperation.py
==============================================================================
--- pypy/dist/pypy/objspace/descroperation.py	(original)
+++ pypy/dist/pypy/objspace/descroperation.py	Sat Mar 12 22:24:56 2005
@@ -283,8 +283,6 @@
 
     _NESTING_LIMIT = 20
 
-    _compare_nesting = 0
-
     def cmp(space, w_v, w_w):
         # Icky implementation trying to mimic python 2.3 semantics.
 
@@ -294,10 +292,14 @@
         w_vt = space.type(w_v)
         token = None
         _inprogress_dict = None
+
+        # um 
+        statedict = space.get_ec_state_dict() 
+        _compare_nesting = statedict.get('_compare_nesting', 0) + 1
+        statedict['_compare_nesting'] = _compare_nesting 
         try:
             # Try to do some magic to compare cyclic constructs.
-            space._compare_nesting += 1
-            if (space._compare_nesting > space._NESTING_LIMIT and
+            if (_compare_nesting > space._NESTING_LIMIT and
                 (space.lookup(w_v, '__getitem__') is not None) and
                 not (space.is_w(w_vt, space.w_str) or
                      space.is_w(w_vt, space.w_tuple))):
@@ -308,7 +310,7 @@
                         t = (iv, iw, -1)
                     else:
                         t = (iw, iv, -1)
-                    _inprogress_dict = space.get_ec_state_dict().setdefault('cmp_state', {})
+                    _inprogress_dict = statedict.setdefault('cmp_state', {})
                     if t in _inprogress_dict:
                         # If we are allready trying to compare the arguments
                         # presume they are equal
@@ -338,7 +340,7 @@
                     except:
                         pass
         finally:
-            space._compare_nesting -= 1
+            statedict['_compare_nesting'] -= 1
 
     def coerce(space, w_obj1, w_obj2):
         w_typ1 = space.type(w_obj1)
@@ -474,10 +476,14 @@
         
         token = None
         _inprogress_dict = None
+
+        # um 
+        statedict = space.get_ec_state_dict() 
+        _compare_nesting = statedict.get('_compare_nesting', 0) + 1
+        statedict['_compare_nesting'] = _compare_nesting 
         try:
             # Try to do some magic to compare cyclic constructs.
-            space._compare_nesting += 1
-            if (space._compare_nesting > space._NESTING_LIMIT and
+            if (_compare_nesting > space._NESTING_LIMIT and
                 (space.lookup(w_obj1, '__getitem__') is not None) and
                 not (space.is_w(w_typ1, space.w_str) or
                      space.is_w(w_typ1, space.w_tuple))):
@@ -520,6 +526,7 @@
             res = space.int_w(w_res)
             return space.wrap(op(res, 0))
         finally:
+            statedict['_compare_nesting'] -= 1 
             if token is not None:
                 try:
                     del _inprogress_dict[token]

Modified: pypy/dist/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/std/objspace.py	(original)
+++ pypy/dist/pypy/objspace/std/objspace.py	Sat Mar 12 22:24:56 2005
@@ -26,6 +26,9 @@
 
     PACKAGE_PATH = 'objspace.std'
 
+    def _freeze_(self): 
+        return True 
+
     def initialize(self):
         "NOT_RPYTHON: only for initializing the space."
         self._typecache = Cache()



More information about the Pypy-commit mailing list