Author: Philip Jenvey <[email protected]>
Branch: py3k-fix-strategies
Changeset: r70737:b9437d441ad2
Date: 2014-04-17 17:41 -0700
http://bitbucket.org/pypy/pypy/changeset/b9437d441ad2/
Log: fix cell/mapdict
diff --git a/pypy/objspace/std/celldict.py b/pypy/objspace/std/celldict.py
--- a/pypy/objspace/std/celldict.py
+++ b/pypy/objspace/std/celldict.py
@@ -63,7 +63,7 @@
def setitem(self, w_dict, w_key, w_value):
space = self.space
- if space.is_w(space.type(w_key), space.w_str):
+ if space.is_w(space.type(w_key), space.w_unicode):
self.setitem_str(w_dict, space.str_w(w_key), w_value)
else:
self.switch_to_object_strategy(w_dict)
@@ -85,7 +85,7 @@
def setdefault(self, w_dict, w_key, w_default):
space = self.space
- if space.is_w(space.type(w_key), space.w_str):
+ if space.is_w(space.type(w_key), space.w_unicode):
key = space.str_w(w_key)
w_result = self.getitem_str(w_dict, key)
if w_result is not None:
@@ -99,7 +99,7 @@
def delitem(self, w_dict, w_key):
space = self.space
w_key_type = space.type(w_key)
- if space.is_w(w_key_type, space.w_str):
+ if space.is_w(w_key_type, space.w_unicode):
key = space.str_w(w_key)
dict_w = self.unerase(w_dict.dstorage)
try:
@@ -120,7 +120,7 @@
def getitem(self, w_dict, w_key):
space = self.space
w_lookup_type = space.type(w_key)
- if space.is_w(w_lookup_type, space.w_str):
+ if space.is_w(w_lookup_type, space.w_unicode):
return self.getitem_str(w_dict, space.str_w(w_key))
elif _never_equal_to_string(space, w_lookup_type):
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -640,7 +640,7 @@
def getitem(self, w_dict, w_key):
space = self.space
w_lookup_type = space.type(w_key)
- if space.is_w(w_lookup_type, space.w_str):
+ if space.is_w(w_lookup_type, space.w_unicode):
return self.getitem_str(w_dict, space.str_w(w_key))
elif _never_equal_to_string(space, w_lookup_type):
return None
@@ -659,7 +659,7 @@
def setitem(self, w_dict, w_key, w_value):
space = self.space
- if space.is_w(space.type(w_key), space.w_str):
+ if space.is_w(space.type(w_key), space.w_unicode):
self.setitem_str(w_dict, self.space.str_w(w_key), w_value)
else:
self.switch_to_object_strategy(w_dict)
@@ -667,7 +667,7 @@
def setdefault(self, w_dict, w_key, w_default):
space = self.space
- if space.is_w(space.type(w_key), space.w_str):
+ if space.is_w(space.type(w_key), space.w_unicode):
key = space.str_w(w_key)
w_result = self.getitem_str(w_dict, key)
if w_result is not None:
@@ -682,7 +682,7 @@
space = self.space
w_key_type = space.type(w_key)
w_obj = self.unerase(w_dict.dstorage)
- if space.is_w(w_key_type, space.w_str):
+ if space.is_w(w_key_type, space.w_unicode):
key = self.space.str_w(w_key)
flag = w_obj.deldictvalue(space, key)
if not flag:
diff --git a/pypy/objspace/std/test/test_celldict.py
b/pypy/objspace/std/test/test_celldict.py
--- a/pypy/objspace/std/test/test_celldict.py
+++ b/pypy/objspace/std/test/test_celldict.py
@@ -4,12 +4,12 @@
from pypy.objspace.std.dictmultiobject import W_DictMultiObject
from pypy.objspace.std.test.test_dictmultiobject import (
BaseTestRDictImplementation, BaseTestDevolvedDictImplementation, FakeSpace,
- FakeString)
+ FakeUnicode)
space = FakeSpace()
class TestCellDict(object):
- FakeString = FakeString
+ FakeString = FakeUnicode
def test_basic_property_cells(self):
strategy = ModuleDictStrategy(space)
@@ -50,10 +50,10 @@
v1 = strategy.version
x = object()
- d.setitem("a", x)
+ d.setitem(u"a", x)
v2 = strategy.version
assert v1 is not v2
- d.setitem("a", x)
+ d.setitem(u"a", x)
v3 = strategy.version
assert v2 is v3
@@ -70,7 +70,7 @@
assert "ModuleDictStrategy" in __pypy__.internal_repr(obj)
def test_check_module_uses_module_dict(self):
- py3k_skip("ModuleDictStrategy is immediately turned into
ObjectDictStrategy because we use unicode keys now")
+ #py3k_skip("ModuleDictStrategy is immediately turned into
ObjectDictStrategy because we use unicode keys now")
m = type(__builtins__)("abc")
self.impl_used(m.__dict__)
@@ -148,7 +148,7 @@
assert x == ("a", 3)
def test_degenerate(self):
- py3k_skip("ModuleDictStrategy is immediately turned into
ObjectDictStrategy because we use unicode keys now")
+ #py3k_skip("ModuleDictStrategy is immediately turned into
ObjectDictStrategy because we use unicode keys now")
import __pypy__
d = self.d
diff --git a/pypy/objspace/std/test/test_dictmultiobject.py
b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -1168,7 +1168,7 @@
class BaseTestRDictImplementation:
FakeString = FakeUnicode
- allows__str = False
+ allows__str = False # XXX: this is maybe not necessary, just add tests to
unicode to ensure we're allowing utf-8?
def setup_method(self,method):
self.fakespace = FakeSpace()
@@ -1290,11 +1290,11 @@
key = self.FakeString(self.string)
x = impl.setdefault(key, 1)
assert x == 1
- if on_pypy:
+ if on_pypy and self.FakeString is FakeString:
assert key.hash_count == 1
x = impl.setdefault(key, 2)
assert x == 1
- if on_pypy:
+ if on_pypy and self.FakeString is FakeString:
assert key.hash_count == 2
def test_fallback_evil_key(self):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit