[pypy-svn] r8596 - in pypy/dist/pypy/objspace/std: . test
mwh at codespeak.net
mwh at codespeak.net
Wed Jan 26 11:47:03 CET 2005
Author: mwh
Date: Wed Jan 26 11:47:03 2005
New Revision: 8596
Modified:
pypy/dist/pypy/objspace/std/dictobject.py
pypy/dist/pypy/objspace/std/test/test_dictobject.py
Log:
Make the dictionary's dummy object a W_Root (an empty list
to be precise) so avoid confusing the annotator.
Fix the tests. Holger, I have another py.test bug to beat you
with :)
Modified: pypy/dist/pypy/objspace/std/dictobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/dictobject.py (original)
+++ pypy/dist/pypy/objspace/std/dictobject.py Wed Jan 26 11:47:03 2005
@@ -10,8 +10,6 @@
from pypy.objspace.std.restricted_int import r_uint
-dummy = object()
-
class Entry:
def __init__(self):
self.hash = r_uint(0)
@@ -29,6 +27,7 @@
w_self.used = 0
w_self.data = []
w_self.resize(len(list_pairs_w)*2)
+ w_self.w_dummy = space.newlist([])
for w_k, w_v in list_pairs_w:
w_self.insert(w_self.hash(w_k), w_k, w_v)
@@ -74,7 +73,7 @@
if entry.w_key is None or \
space.is_true(space.is_(w_lookup, entry.w_key)):
return entry
- if entry.w_key is dummy:
+ if entry.w_key is self.w_dummy:
freeslot = entry
else:
if entry.hash == lookup_hash and space.is_true(
@@ -91,11 +90,11 @@
return freeslot
else:
return entry
- if entry.hash == lookup_hash and entry.w_key is not dummy \
+ if entry.hash == lookup_hash and entry.w_key is not self.w_dummy \
and space.is_true(
space.eq(entry.w_key, w_lookup)):
return entry
- if entry.w_key is dummy and freeslot is None:
+ if entry.w_key is self.w_dummy and freeslot is None:
freeslot = entry
perturb >>= 5
@@ -150,7 +149,7 @@
entry = w_dict.lookdict(w_dict.hash(w_lookup), w_lookup)
if entry.w_value is not None:
w_dict.used -= 1
- entry.w_key = dummy
+ entry.w_key = w_dict.w_dummy
entry.w_value = None
else:
raise OperationError(space.w_KeyError, w_lookup)
Modified: pypy/dist/pypy/objspace/std/test/test_dictobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_dictobject.py (original)
+++ pypy/dist/pypy/objspace/std/test/test_dictobject.py Wed Jan 26 11:47:03 2005
@@ -308,6 +308,8 @@
return x is y
def eq(self, x, y):
return x == y
+ def newlist(self, l):
+ return []
from pypy.objspace.std.dictobject import getitem__Dict_ANY, setitem__Dict_ANY_ANY
More information about the Pypy-commit
mailing list