[pypy-commit] pypy py3k: merge upstream

pjenvey noreply at buildbot.pypy.org
Wed Apr 30 01:12:11 CEST 2014


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r71081:e43a6cc83813
Date: 2014-04-29 16:10 -0700
http://bitbucket.org/pypy/pypy/changeset/e43a6cc83813/

Log:	merge upstream

diff --git a/lib_pypy/_testcapi.py b/lib_pypy/_testcapi.py
--- a/lib_pypy/_testcapi.py
+++ b/lib_pypy/_testcapi.py
@@ -1,4 +1,5 @@
-import imp, os
+import imp
+import os
 
 try:
     import cpyext
@@ -12,6 +13,9 @@
 
 try:
     fp, filename, description = imp.find_module('_testcapi', path=[output_dir])
-    imp.load_module('_testcapi', fp, filename, description)
+    try:
+        imp.load_module('_testcapi', fp, filename, description)
+    finally:
+        fp.close()
 except ImportError:
     _pypy_testcapi.compile_shared(cfile, '_testcapi', output_dir)
diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py
--- a/pypy/interpreter/argument.py
+++ b/pypy/interpreter/argument.py
@@ -351,7 +351,7 @@
                 limit -= len(self.keyword_names_w)
             for i in range(len(self.keywords)):
                 if i < limit:
-                    w_key = space.wrap(self.keywords[i])
+                    w_key = space.wrap(self.keywords[i].decode('utf-8'))
                 else:
                     w_key = self.keyword_names_w[i - limit]
                 space.setitem(w_kwds, w_key, self.keywords_w[i])
@@ -446,7 +446,7 @@
                 break
         else:
             if i < limit:
-                w_key = space.wrap(keywords[i])
+                w_key = space.wrap(keywords[i].decode('utf-8'))
             else:
                 w_key = keyword_names_w[i - limit]
             space.setitem(w_kwds, w_key, keywords_w[i])
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -433,6 +433,9 @@
     def getconstant_w(self, index):
         return self.getcode().co_consts_w[index]
 
+    def getname_u(self, index):
+        return self.space.identifier_w(self.getname_w(index))
+
     def getname_w(self, index):
         return self.getcode().co_names_w[index]
 
@@ -753,9 +756,9 @@
         self.pushvalue(w_build_class)
 
     def STORE_NAME(self, varindex, next_instr):
-        w_varname = self.getname_w(varindex)
+        varname = self.getname_u(varindex)
         w_newvalue = self.popvalue()
-        self.space.setitem(self.w_locals, w_varname, w_newvalue)
+        self.space.setitem_str(self.w_locals, varname, w_newvalue)
 
     def DELETE_NAME(self, varindex, next_instr):
         w_varname = self.getname_w(varindex)
@@ -765,8 +768,8 @@
             # catch KeyErrors and turn them into NameErrors
             if not e.match(self.space, self.space.w_KeyError):
                 raise
-            raise oefmt(self.space.w_NameError, "name '%s' is not defined",
-                        self.space.str_w(w_varname))
+            raise oefmt(self.space.w_NameError,
+                        "name %R is not defined", w_varname)
 
     def UNPACK_SEQUENCE(self, itemcount, next_instr):
         w_iterable = self.popvalue()
@@ -817,7 +820,7 @@
         self.space.delattr(w_obj, w_attributename)
 
     def STORE_GLOBAL(self, nameindex, next_instr):
-        varname = self.space.str_w(self.getname_w(nameindex))
+        varname = self.getname_u(nameindex)
         w_newvalue = self.popvalue()
         self.space.setitem_str(self.w_globals, varname, w_newvalue)
 
@@ -827,24 +830,24 @@
 
     def LOAD_NAME(self, nameindex, next_instr):
         w_varname = self.getname_w(nameindex)
+        varname = self.space.identifier_w(w_varname)
         if self.w_locals is not self.w_globals:
-            w_value = self.space.finditem(self.w_locals, w_varname)
+            w_value = self.space.finditem_str(self.w_locals, varname)
             if w_value is not None:
                 self.pushvalue(w_value)
                 return
         # fall-back
-        w_value = self._load_global(w_varname)
+        w_value = self._load_global(varname)
         if w_value is None:
             raise oefmt(self.space.w_NameError,
                         "name %R is not defined", w_varname)
         self.pushvalue(w_value)
 
-    def _load_global(self, w_varname):
-        w_value = self.space.finditem(self.w_globals, w_varname)
+    def _load_global(self, varname):
+        w_value = self.space.finditem_str(self.w_globals, varname)
         if w_value is None:
             # not in the globals, now look in the built-ins
-            w_value = self.get_builtin().getdictvalue(
-                self.space, self.space.identifier_w(w_varname))
+            w_value = self.get_builtin().getdictvalue(self.space, varname)
         return w_value
     _load_global._always_inline_ = True
 
@@ -855,7 +858,7 @@
 
     def LOAD_GLOBAL(self, nameindex, next_instr):
         w_varname = self.getname_w(nameindex)
-        w_value = self._load_global(w_varname)
+        w_value = self._load_global(self.space.identifier_w(w_varname))
         if w_value is None:
             self._load_global_failed(w_varname)
         self.pushvalue(w_value)
@@ -993,7 +996,7 @@
             if not e.match(self.space, self.space.w_AttributeError):
                 raise
             raise oefmt(self.space.w_ImportError,
-                        "cannot import name '%s'", self.space.str_w(w_name))
+                        "cannot import name %R", w_name)
         self.pushvalue(w_obj)
 
     def YIELD_VALUE(self, oparg, next_instr):
diff --git a/pypy/module/__pypy__/test/test_special.py b/pypy/module/__pypy__/test/test_special.py
--- a/pypy/module/__pypy__/test/test_special.py
+++ b/pypy/module/__pypy__/test/test_special.py
@@ -75,21 +75,18 @@
         assert x == 42
 
     def test_list_strategy(self):
-        py3k_skip("XXX: strategies are currently broken")
         from __pypy__ import list_strategy
 
         l = [1, 2, 3]
         assert list_strategy(l) == "int"
+        l = list(range(1, 2))
+        assert list_strategy(l) == "int"
         l = [b"a", b"b", b"c"]
         assert list_strategy(l) == "bytes"
         l = ["a", "b", "c"]
         assert list_strategy(l) == "unicode"
         l = [1.1, 2.2, 3.3]
         assert list_strategy(l) == "float"
-        l = range(3)
-        assert list_strategy(l) == "simple_range"
-        l = range(1, 2)
-        assert list_strategy(l) == "range"
         l = [1, "b", 3]
         assert list_strategy(l) == "object"
         l = []
diff --git a/pypy/module/_cffi_backend/test/test_fastpath.py b/pypy/module/_cffi_backend/test/test_fastpath.py
--- a/pypy/module/_cffi_backend/test/test_fastpath.py
+++ b/pypy/module/_cffi_backend/test/test_fastpath.py
@@ -16,7 +16,6 @@
         W_CType.pack_list_of_items = self._original
 
     def test_fast_init_from_list(self):
-        py3k_skip('XXX: strategies are currently broken')
         import _cffi_backend
         LONG = _cffi_backend.new_primitive_type('long')
         P_LONG = _cffi_backend.new_pointer_type(LONG)
@@ -37,7 +36,6 @@
         assert buf[2] == 3.3
 
     def test_fast_init_short_from_list(self):
-        py3k_skip('XXX: strategies are currently broken')
         import _cffi_backend
         SHORT = _cffi_backend.new_primitive_type('short')
         P_SHORT = _cffi_backend.new_pointer_type(SHORT)
@@ -50,7 +48,6 @@
         raises(OverflowError, _cffi_backend.newp, SHORT_ARRAY, [-40000])
 
     def test_fast_init_longlong_from_list(self):
-        py3k_skip('XXX: strategies are currently broken')
         import _cffi_backend
         import sys
         large_int = 2 ** (50 if sys.maxsize > 2**31 - 1 else 30)
@@ -64,7 +61,6 @@
         assert buf[3] == large_int
 
     def test_fast_init_ushort_from_list(self):
-        py3k_skip('XXX: strategies are currently broken')
         import _cffi_backend
         USHORT = _cffi_backend.new_primitive_type('unsigned short')
         P_USHORT = _cffi_backend.new_pointer_type(USHORT)
@@ -77,18 +73,17 @@
         raises(OverflowError, _cffi_backend.newp, USHORT_ARRAY, [-1])
 
     def test_fast_init_ulong_from_list(self):
-        py3k_skip('XXX: strategies are currently broken')
         import sys
         import _cffi_backend
         ULONG = _cffi_backend.new_primitive_type('unsigned long')
         P_ULONG = _cffi_backend.new_pointer_type(ULONG)
         ULONG_ARRAY = _cffi_backend.new_array_type(P_ULONG, None)
-        buf = _cffi_backend.newp(ULONG_ARRAY, [1, 2, sys.maxint])
+        buf = _cffi_backend.newp(ULONG_ARRAY, [1, 2, sys.maxsize])
         assert buf[0] == 1
         assert buf[1] == 2
-        assert buf[2] == sys.maxint
+        assert buf[2] == sys.maxsize
         raises(OverflowError, _cffi_backend.newp, ULONG_ARRAY, [-1])
-        raises(OverflowError, _cffi_backend.newp, ULONG_ARRAY, [-sys.maxint])
+        raises(OverflowError, _cffi_backend.newp, ULONG_ARRAY, [-sys.maxsize])
 
     def test_fast_init_cfloat_from_list(self):
         import _cffi_backend
@@ -109,7 +104,6 @@
         assert float(buf[1]) == -3.5
 
     def test_fast_init_bool_from_list(self):
-        py3k_skip('XXX: strategies are currently broken')
         import _cffi_backend
         BOOL = _cffi_backend.new_primitive_type('_Bool')
         P_BOOL = _cffi_backend.new_pointer_type(BOOL)
diff --git a/pypy/module/_posixsubprocess/interp_subprocess.py b/pypy/module/_posixsubprocess/interp_subprocess.py
--- a/pypy/module/_posixsubprocess/interp_subprocess.py
+++ b/pypy/module/_posixsubprocess/interp_subprocess.py
@@ -219,7 +219,8 @@
 
 
 def cloexec_pipe(space):
-    """"cloexec_pipe() -> (read_end, write_end)
+    """cloexec_pipe() -> (read_end, write_end)
+
     Create a pipe whose ends have the cloexec flag set."""
 
     with lltype.scoped_alloc(rffi.CArrayPtr(rffi.INT).TO, 2) as fds:
diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -409,7 +409,7 @@
         raise OperationError(space.w_TypeError, space.wrap(
             "Cannot use string as modifiable buffer"))
 
-    def listview_bytes(self):
+    def listview_int(self):
         return _create_list_from_bytes(self._value)
 
     def ord(self, space):
@@ -632,8 +632,8 @@
         l = space.listview_bytes(w_list)
         if l is not None:
             if len(l) == 1:
-                return space.wrap(l[0])
-            return space.wrap(self._val(space).join(l))
+                return space.wrapbytes(l[0])
+            return space.wrapbytes(self._val(space).join(l))
         return self._StringMethods_descr_join(space, w_list)
 
     def _join_return_one(self, space, w_obj):
@@ -657,8 +657,8 @@
 
 def _create_list_from_bytes(value):
     # need this helper function to allow the jit to look inside and inline
-    # listview_bytes
-    return [s for s in value]
+    # listview_int
+    return [ord(s) for s in value]
 
 W_BytesObject.EMPTY = W_BytesObject('')
 W_BytesObject.PREBUILT = [W_BytesObject(chr(i)) for i in range(256)]
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
@@ -30,7 +30,7 @@
 
 
 def _wrapkey(space, key):
-    return space.wrap(key)
+    return space.wrap(key.decode('utf-8'))
 
 
 class ModuleDictStrategy(DictStrategy):
@@ -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/dictmultiobject.py b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -55,10 +55,10 @@
         elif space.config.objspace.std.withmapdict and instance:
             from pypy.objspace.std.mapdict import MapDictStrategy
             strategy = space.fromcache(MapDictStrategy)
-        #elif instance or strdict or module:
-        #    assert w_type is None
-        #    strategy = space.fromcache(BytesDictStrategy)
-        elif False and kwargs:
+        elif instance or strdict or module:
+            assert w_type is None
+            strategy = space.fromcache(UnicodeDictStrategy)
+        elif kwargs:
             assert w_type is None
             from pypy.objspace.std.kwargsdict import EmptyKwargsDictStrategy
             strategy = space.fromcache(EmptyKwargsDictStrategy)
@@ -113,14 +113,15 @@
         if w_fill is None:
             w_fill = space.w_None
         if space.is_w(w_type, space.w_dict):
-            w_dict = W_DictMultiObject.allocate_and_init_instance(space,
-                                                                  w_type)
-
-            byteslist = space.listview_bytes(w_keys)
-            if byteslist is not None:
-                for key in byteslist:
-                    w_dict.setitem_str(key, w_fill)
+            ulist = space.listview_unicode(w_keys)
+            if ulist is not None:
+                strategy = space.fromcache(UnicodeDictStrategy)
+                storage = strategy.get_storage_fromkeys(ulist, w_fill)
+                w_dict = space.allocate_instance(W_DictMultiObject, w_type)
+                W_DictMultiObject.__init__(w_dict, space, strategy, storage)
             else:
+                w_dict = W_DictMultiObject.allocate_and_init_instance(space,
+                                                                      w_type)
                 for w_key in space.listview(w_keys):
                     w_dict.setitem(w_key, w_fill)
         else:
@@ -360,6 +361,9 @@
     def get_empty_storage(self):
         raise NotImplementedError
 
+    def decodekey_str(self, key):
+        return key.decode('utf-8')
+
     @jit.look_inside_iff(lambda self, w_dict:
                          w_dict_unrolling_heuristic(w_dict))
     def w_keys(self, w_dict):
@@ -430,18 +434,18 @@
         return self.erase(None)
 
     def switch_to_correct_strategy(self, w_dict, w_key):
+        from pypy.objspace.std.intobject import W_IntObject
         withidentitydict = self.space.config.objspace.std.withidentitydict
-        # if type(w_key) is self.space.StringObjectCls:
-        #     self.switch_to_bytes_strategy(w_dict)
-        #     return
+        if type(w_key) is self.space.StringObjectCls:
+            self.switch_to_bytes_strategy(w_dict)
+            return
         if type(w_key) is self.space.UnicodeObjectCls:
             self.switch_to_unicode_strategy(w_dict)
             return
+        if type(w_key) is W_IntObject:
+            self.switch_to_int_strategy(w_dict)
+            return
         w_type = self.space.type(w_key)
-        # XXX: disable IntDictStrategy for now, because in py3k ints are
-        # actually long
-        ## if self.space.is_w(w_type, self.space.w_int):
-        ##     self.switch_to_int_strategy(w_dict)
         if withidentitydict and w_type.compares_by_identity():
             self.switch_to_identity_strategy(w_dict)
         else:
@@ -500,7 +504,7 @@
         w_dict.setitem(w_key, w_value)
 
     def setitem_str(self, w_dict, key, w_value):
-        self.switch_to_bytes_strategy(w_dict)
+        self.switch_to_unicode_strategy(w_dict)
         w_dict.setitem_str(key, w_value)
 
     def delitem(self, w_dict, w_key):
@@ -700,7 +704,7 @@
 
     def setitem_str(self, w_dict, key, w_value):
         self.switch_to_object_strategy(w_dict)
-        w_dict.setitem(self.space.wrap(key), w_value)
+        w_dict.setitem(self.space.wrap(self.decodekey_str(key)), w_value)
 
     def setdefault(self, w_dict, w_key, w_default):
         if self.is_correct_type(w_key):
@@ -722,7 +726,7 @@
         return len(self.unerase(w_dict.dstorage))
 
     def getitem_str(self, w_dict, key):
-        return self.getitem(w_dict, self.space.wrap(key))
+        return self.getitem(w_dict, self.space.wrap(self.decodekey_str(key)))
 
     def getitem(self, w_dict, w_key):
         space = self.space
@@ -802,7 +806,7 @@
         return self.space.newlist(self.unerase(w_dict.dstorage).keys())
 
     def setitem_str(self, w_dict, s, w_value):
-        self.setitem(w_dict, self.space.wrap(s), w_value)
+        self.setitem(w_dict, self.space.wrap(self.decodekey_str(s)), w_value)
 
     def switch_to_object_strategy(self, w_dict):
         assert 0, "should be unreachable"
@@ -816,10 +820,10 @@
     unerase = staticmethod(unerase)
 
     def wrap(self, unwrapped):
-        return self.space.wrap(unwrapped)
+        return self.space.wrapbytes(unwrapped)
 
     def unwrap(self, wrapped):
-        return self.space.str_w(wrapped)
+        return self.space.bytes_w(wrapped)
 
     def is_correct_type(self, w_obj):
         space = self.space
@@ -833,21 +837,21 @@
     def _never_equal_to(self, w_lookup_type):
         return _never_equal_to_string(self.space, w_lookup_type)
 
-    def setitem_str(self, w_dict, key, w_value):
-        assert key is not None
-        self.unerase(w_dict.dstorage)[key] = w_value
+    ##def setitem_str(self, w_dict, key, w_value):
+    ##    assert key is not None
+    ##    self.unerase(w_dict.dstorage)[key] = w_value
 
-    def getitem(self, w_dict, w_key):
-        space = self.space
-        # -- This is called extremely often.  Hack for performance --
-        if type(w_key) is space.StringObjectCls:
-            return self.getitem_str(w_dict, w_key.unwrap(space))
-        # -- End of performance hack --
-        return AbstractTypedStrategy.getitem(self, w_dict, w_key)
+    ##def getitem(self, w_dict, w_key):
+    ##    space = self.space
+    ##    # -- This is called extremely often.  Hack for performance --
+    ##    if type(w_key) is space.StringObjectCls:
+    ##        return self.unerase(w_dict.dstorage).get(self.unwrap(w_key), None)
+    ##    # -- End of performance hack --
+    ##    return AbstractTypedStrategy.getitem(self, w_dict, w_key)
 
-    def getitem_str(self, w_dict, key):
-        assert key is not None
-        return self.unerase(w_dict.dstorage).get(key, None)
+    ##def getitem_str(self, w_dict, key):
+    ##    assert key is not None
+    ##    return self.unerase(w_dict.dstorage).get(key, None)
 
     def listview_bytes(self, w_dict):
         return self.unerase(w_dict.dstorage).keys()
@@ -856,21 +860,21 @@
         return self.space.newlist_bytes(self.listview_bytes(w_dict))
 
     def wrapkey(space, key):
-        return space.wrap(key)
+        return space.wrapbytes(key)
 
-    @jit.look_inside_iff(lambda self, w_dict:
-                         w_dict_unrolling_heuristic(w_dict))
-    def view_as_kwargs(self, w_dict):
-        return (None, None) # XXX: fix me to return unicode keys
-        d = self.unerase(w_dict.dstorage)
-        l = len(d)
-        keys, values = [None] * l, [None] * l
-        i = 0
-        for key, val in d.iteritems():
-            keys[i] = key
-            values[i] = val
-            i += 1
-        return keys, values
+    ##@jit.look_inside_iff(lambda self, w_dict:
+    ##                     w_dict_unrolling_heuristic(w_dict))
+    ##def view_as_kwargs(self, w_dict):
+    ##    return (None, None) # XXX: fix me to return unicode keys
+    ##    d = self.unerase(w_dict.dstorage)
+    ##    l = len(d)
+    ##    keys, values = [None] * l, [None] * l
+    ##    i = 0
+    ##    for key, val in d.iteritems():
+    ##        keys[i] = key
+    ##        values[i] = val
+    ##        i += 1
+    ##    return keys, values
 
 create_iterator_classes(BytesDictStrategy)
 
@@ -900,43 +904,51 @@
 
     # we should implement the same shortcuts as we do for BytesDictStrategy
 
-    ## def setitem_str(self, w_dict, key, w_value):
-    ##     assert key is not None
-    ##     self.unerase(w_dict.dstorage)[key] = w_value
+    def setitem_str(self, w_dict, key, w_value):
+        assert key is not None
+        self.unerase(w_dict.dstorage)[self.decodekey_str(key)] = w_value
 
-    ## def getitem(self, w_dict, w_key):
-    ##     space = self.space
-    ##     # -- This is called extremely often.  Hack for performance --
-    ##     if type(w_key) is space.StringObjectCls:
-    ##         return self.getitem_str(w_dict, w_key.unwrap(space))
-    ##     # -- End of performance hack --
-    ##     return AbstractTypedStrategy.getitem(self, w_dict, w_key)
+    def getitem(self, w_dict, w_key):
+        space = self.space
+        # -- This is called extremely often.  Hack for performance --
+        if type(w_key) is space.UnicodeObjectCls:
+            return self.unerase(w_dict.dstorage).get(w_key.unwrap(space), None)
+        # -- End of performance hack --
+        return AbstractTypedStrategy.getitem(self, w_dict, w_key)
 
-    ## def getitem_str(self, w_dict, key):
-    ##     assert key is not None
-    ##     return self.unerase(w_dict.dstorage).get(key, None)
+    def getitem_str(self, w_dict, key):
+        assert key is not None
+        return self.unerase(w_dict.dstorage).get(self.decodekey_str(key), None)
 
     def listview_unicode(self, w_dict):
         return self.unerase(w_dict.dstorage).keys()
 
-    ## def w_keys(self, w_dict):
-    ##     return self.space.newlist_bytes(self.listview_bytes(w_dict))
+    def w_keys(self, w_dict):
+        return self.space.newlist_unicode(self.listview_unicode(w_dict))
 
     def wrapkey(space, key):
         return space.wrap(key)
 
-    ## @jit.look_inside_iff(lambda self, w_dict:
-    ##                      w_dict_unrolling_heuristic(w_dict))
-    ## def view_as_kwargs(self, w_dict):
-    ##     d = self.unerase(w_dict.dstorage)
-    ##     l = len(d)
-    ##     keys, values = [None] * l, [None] * l
-    ##     i = 0
-    ##     for key, val in d.iteritems():
-    ##         keys[i] = key
-    ##         values[i] = val
-    ##         i += 1
-    ##     return keys, values
+    @jit.look_inside_iff(lambda self, w_dict:
+                         w_dict_unrolling_heuristic(w_dict))
+    def view_as_kwargs(self, w_dict):
+        d = self.unerase(w_dict.dstorage)
+        l = len(d)
+        keys, values = [None] * l, [None] * l
+        i = 0
+        for key, val in d.iteritems():
+            keys[i] = key.encode('utf-8')
+            values[i] = val
+            i += 1
+        return keys, values
+
+    def get_storage_fromkeys(self, keys_w, w_fill):
+        """Return an initialized storage with keys and fill values"""
+        storage = {}
+        mark_dict_non_null(storage)
+        for key in keys_w:
+            storage[key] = w_fill
+        return self.erase(storage)
 
 create_iterator_classes(UnicodeDictStrategy)
 
@@ -956,8 +968,8 @@
         return self.erase({})
 
     def is_correct_type(self, w_obj):
-        space = self.space
-        return space.is_w(space.type(w_obj), space.w_int)
+        from pypy.objspace.std.intobject import W_IntObject
+        return type(w_obj) is W_IntObject
 
     def _never_equal_to(self, w_lookup_type):
         space = self.space
diff --git a/pypy/objspace/std/kwargsdict.py b/pypy/objspace/std/kwargsdict.py
--- a/pypy/objspace/std/kwargsdict.py
+++ b/pypy/objspace/std/kwargsdict.py
@@ -6,16 +6,16 @@
 from rpython.rlib import jit, rerased
 
 from pypy.objspace.std.dictmultiobject import (
-    BytesDictStrategy, DictStrategy, EmptyDictStrategy, ObjectDictStrategy,
+    DictStrategy, EmptyDictStrategy, ObjectDictStrategy, UnicodeDictStrategy,
     create_iterator_classes)
 
 
 def _wrapkey(space, key):
-    return space.wrap(key)
+    return space.wrap(key.decode('utf-8'))
 
 
 class EmptyKwargsDictStrategy(EmptyDictStrategy):
-    def switch_to_bytes_strategy(self, w_dict):
+    def switch_to_unicode_strategy(self, w_dict):
         strategy = self.space.fromcache(KwargsDictStrategy)
         storage = strategy.get_empty_storage()
         w_dict.strategy = strategy
@@ -39,7 +39,7 @@
 
     def is_correct_type(self, w_obj):
         space = self.space
-        return space.is_w(space.type(w_obj), space.w_str)
+        return space.is_w(space.type(w_obj), space.w_unicode)
 
     def _never_equal_to(self, w_lookup_type):
         return False
@@ -66,7 +66,7 @@
         else:
             # limit the size so that the linear searches don't become too long
             if len(keys) >= 16:
-                self.switch_to_bytes_strategy(w_dict)
+                self.switch_to_unicode_strategy(w_dict)
                 w_dict.setitem_str(key, w_value)
             else:
                 keys.append(key)
@@ -116,7 +116,7 @@
 
     def w_keys(self, w_dict):
         l = self.unerase(w_dict.dstorage)[0]
-        return self.space.newlist_bytes(l[:])
+        return self.space.newlist_unicode(l[:])
 
     def values(self, w_dict):
         return self.unerase(w_dict.dstorage)[1][:] # to make non-resizable
@@ -145,13 +145,13 @@
         w_dict.strategy = strategy
         w_dict.dstorage = strategy.erase(d_new)
 
-    def switch_to_bytes_strategy(self, w_dict):
-        strategy = self.space.fromcache(BytesDictStrategy)
+    def switch_to_unicode_strategy(self, w_dict):
+        strategy = self.space.fromcache(UnicodeDictStrategy)
         keys, values_w = self.unerase(w_dict.dstorage)
         storage = strategy.get_empty_storage()
         d_new = strategy.unerase(storage)
         for i in range(len(keys)):
-            d_new[keys[i]] = values_w[i]
+            d_new[self.decodekey_str(keys[i])] = values_w[i]
         w_dict.strategy = strategy
         w_dict.dstorage = storage
 
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -80,14 +80,11 @@
         return space.fromcache(IntegerListStrategy)
 
     # check for strings
-    # XXX: StringListStrategy is currently broken
-    """
     for w_obj in list_w:
         if not type(w_obj) is W_BytesObject:
             break
     else:
         return space.fromcache(BytesListStrategy)
-        """
 
     # check for unicode
     for w_obj in list_w:
@@ -166,12 +163,11 @@
             self.switch_to_object_strategy()
         return self
 
-    # XXX: BytesListStrategy is currently broken
-    #@staticmethod
-    #def newlist_bytes(space, list_b):
-    #    strategy = space.fromcache(BytesListStrategy)
-    #    storage = strategy.erase(list_b)
-    #    return W_ListObject.from_storage_and_strategy(space, storage, strategy)
+    @staticmethod
+    def newlist_bytes(space, list_b):
+        strategy = space.fromcache(BytesListStrategy)
+        storage = strategy.erase(list_b)
+        return W_ListObject.from_storage_and_strategy(space, storage, strategy)
 
     @staticmethod
     def newlist_unicode(space, list_u):
@@ -875,8 +871,8 @@
     def switch_to_correct_strategy(self, w_list, w_item):
         if type(w_item) is W_IntObject:
             strategy = self.space.fromcache(IntegerListStrategy)
-        #elif type(w_item) is W_BytesObject:
-        #    strategy = self.space.fromcache(BytesListStrategy)
+        elif type(w_item) is W_BytesObject:
+            strategy = self.space.fromcache(BytesListStrategy)
         elif type(w_item) is W_UnicodeObject:
             strategy = self.space.fromcache(UnicodeListStrategy)
         elif type(w_item) is W_FloatObject:
@@ -1662,7 +1658,7 @@
         return self.space.wrapbytes(stringval)
 
     def unwrap(self, w_string):
-        return self.space.str_w(w_string)
+        return self.space.bytes_w(w_string)
 
     erase, unerase = rerased.new_erasing_pair("bytes")
     erase = staticmethod(erase)
@@ -1778,7 +1774,7 @@
     def lt(self, a, b):
         return a < b
 
-class StringSort(UnicodeBaseTimSort):
+class StringSort(StringBaseTimSort):
     def lt(self, a, b):
         return a < b
 
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/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -316,10 +316,8 @@
         assert not list_w or sizehint == -1
         return W_ListObject(self, list_w, sizehint)
 
-    # XXX: BytesListStrategy is currently broken use the default
-    # implementation, which simply wraps
-    #def newlist_bytes(self, list_s):
-    #    return W_ListObject.newlist_bytes(self, list_s)
+    def newlist_bytes(self, list_s):
+        return W_ListObject.newlist_bytes(self, list_s)
 
     def newlist_unicode(self, list_u):
         return W_ListObject.newlist_unicode(self, list_u)
@@ -502,6 +500,9 @@
             return w_obj.listview_int()
         if type(w_obj) is W_SetObject or type(w_obj) is W_FrozensetObject:
             return w_obj.listview_int()
+        if type(w_obj) is W_BytesObject:
+            # Python3 considers bytes strings as a list of numbers.
+            return w_obj.listview_int()
         if isinstance(w_obj, W_ListObject) and self._uses_list_iter(w_obj):
             return w_obj.getitems_int()
         return None
diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -1439,7 +1439,7 @@
 
     def next_entry(self):
         for key in self.iterator:
-            return self.space.wrap(key)
+            return self.space.wrapbytes(key)
         else:
             return None
 
diff --git a/pypy/objspace/std/test/test_bytesobject.py b/pypy/objspace/std/test/test_bytesobject.py
--- a/pypy/objspace/std/test/test_bytesobject.py
+++ b/pypy/objspace/std/test/test_bytesobject.py
@@ -82,10 +82,11 @@
         w_slice = space.newslice(w(1), w_None, w(2))
         assert self.space.eq_w(space.getitem(w_str, w_slice), wb('el'))
 
-    def test_listview_bytes(self):
+    def test_listview_bytes_int(self):
         w_bytes = self.space.wrapbytes('abcd')
         # list(b'abcd') is a list of numbers
         assert self.space.listview_bytes(w_bytes) == None
+        assert self.space.listview_int(w_bytes) == [97, 98, 99, 100]
 
 class AppTestBytesObject:
 
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
@@ -1,15 +1,16 @@
+# encoding: utf-8
 import py
 
 from pypy.objspace.std.celldict import ModuleDictStrategy
 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 +51,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 +71,6 @@
         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")
         m = type(__builtins__)("abc")
         self.impl_used(m.__dict__)
 
@@ -133,9 +133,12 @@
     def setup_class(cls):
         if cls.runappdirect:
             py.test.skip("__repr__ doesn't work on appdirect")
-        strategy = ModuleDictStrategy(cls.space)
+
+    def setup_method(self, method):
+        space = self.space
+        strategy = ModuleDictStrategy(space)
         storage = strategy.get_empty_storage()
-        cls.w_d = W_DictMultiObject(cls.space, strategy, storage)
+        self.w_d = W_DictMultiObject(space, strategy, storage)
 
     def test_popitem(self):
         import __pypy__
@@ -148,7 +151,6 @@
         assert x == ("a", 3)
 
     def test_degenerate(self):
-        py3k_skip("ModuleDictStrategy is immediately turned into ObjectDictStrategy because we use unicode keys now")
         import __pypy__
 
         d = self.d
@@ -157,3 +159,23 @@
         del d["a"]
         d[object()] = 5
         assert list(d.values()) == [5]
+
+    def test_unicode(self):
+        import __pypy__
+
+        d = self.d
+        assert "ModuleDict" in __pypy__.internal_repr(d)
+        d['λ'] = True
+        assert "ModuleDict" in __pypy__.internal_repr(d)
+        assert list(d) == ['λ']
+        assert next(iter(d)) == 'λ'
+        assert "ModuleDict" in __pypy__.internal_repr(d)
+
+        d['foo'] = 'bar'
+        assert sorted(d) == ['foo', 'λ']
+        assert "ModuleDict" in __pypy__.internal_repr(d)
+
+        o = object()
+        d[o] = 'baz'
+        assert set(d) == set(['foo', 'λ', o])
+        assert "ObjectDictStrategy" in __pypy__.internal_repr(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
@@ -3,7 +3,7 @@
 import py
 
 from pypy.objspace.std.dictmultiobject import (W_DictMultiObject,
-    BytesDictStrategy, ObjectDictStrategy)
+    BytesDictStrategy, ObjectDictStrategy, UnicodeDictStrategy)
 
 
 class TestW_DictObject(object):
@@ -125,12 +125,10 @@
         assert self.space.eq_w(space.call_function(get, w("33"), w(44)), w(44))
 
     def test_fromkeys_fastpath(self):
-        py.test.py3k_skip("XXX: strategies are currently broken")
         space = self.space
         w = space.wrap
-        wb = space.wrapbytes
 
-        w_l = self.space.newlist([wb("a"),wb("b")])
+        w_l = space.newlist([w("a"),w("b")])
         w_l.getitems = None
         w_d = space.call_method(space.w_dict, "fromkeys", w_l)
 
@@ -138,7 +136,6 @@
         assert space.eq_w(w_d.getitem_str("b"), space.w_None)
 
     def test_listview_bytes_dict(self):
-        py.test.py3k_skip("XXX: strategies are currently broken")
         w = self.space.wrap
         wb = self.space.wrapbytes
         w_d = self.space.newdict()
@@ -152,30 +149,30 @@
         assert self.space.listview_unicode(w_d) == [u"a", u"b"]
 
     def test_listview_int_dict(self):
-        py.test.py3k_skip("IntDictStrategy not supported yet")
         w = self.space.wrap
         w_d = self.space.newdict()
         w_d.initialize_content([(w(1), w("a")), (w(2), w("b"))])
         assert self.space.listview_int(w_d) == [1, 2]
 
     def test_keys_on_string_unicode_int_dict(self, monkeypatch):
-        py.test.py3k_skip("XXX: strategies are currently broken")
         w = self.space.wrap
         wb = self.space.wrapbytes
         
         w_d = self.space.newdict()
         w_d.initialize_content([(w(1), wb("a")), (w(2), wb("b"))])
-        w_l = self.space.call_method(w_d, "keys")
+        w_k = self.space.call_method(w_d, "keys")
+        w_l = self.space.call_function(self.space.w_list, w_k)
         assert sorted(self.space.listview_int(w_l)) == [1,2]
         
-        # make sure that .keys() calls newlist_bytes for string dicts
+        # make sure that list(d.keys()) calls newlist_bytes for byte dicts
         def not_allowed(*args):
             assert False, 'should not be called'
         monkeypatch.setattr(self.space, 'newlist', not_allowed)
         #
         w_d = self.space.newdict()
-        w_d.initialize_content([(w("a"), w(1)), (w("b"), w(6))])
-        w_l = self.space.call_method(w_d, "keys")
+        w_d.initialize_content([(wb("a"), w(1)), (wb("b"), w(6))])
+        w_k = self.space.call_method(w_d, "keys")
+        w_l = self.space.call_function(self.space.w_list, w_k)
         assert sorted(self.space.listview_bytes(w_l)) == ["a", "b"]
 
         # XXX: it would be nice if the test passed without monkeypatch.undo(),
@@ -183,7 +180,8 @@
         monkeypatch.undo() 
         w_d = self.space.newdict()
         w_d.initialize_content([(w(u"a"), w(1)), (w(u"b"), w(6))])
-        w_l = self.space.call_method(w_d, "keys")
+        w_k = self.space.call_method(w_d, "keys")
+        w_l = self.space.call_function(self.space.w_list, w_k)
         assert sorted(self.space.listview_unicode(w_l)) == [u"a", u"b"]
 
 class AppTest_DictObject:
@@ -952,10 +950,9 @@
         return r[r.find("(") + 1: r.find(")")]
 
     def test_empty_to_string(self):
-        py3k_skip("StringDictStrategy not supported yet")
         d = {}
         assert "EmptyDictStrategy" in self.get_strategy(d)
-        d["a"] = 1
+        d[b"a"] = 1
         assert "BytesDictStrategy" in self.get_strategy(d)
 
         class O(object):
@@ -964,7 +961,7 @@
         d = o.__dict__ = {}
         assert "EmptyDictStrategy" in self.get_strategy(d)
         o.a = 1
-        assert "BytesDictStrategy" in self.get_strategy(d)
+        assert "UnicodeDictStrategy" in self.get_strategy(d)
 
     def test_empty_to_unicode(self):
         d = {}
@@ -1017,9 +1014,16 @@
         # gives us (1, 2), but 1 is not in the dict any longer.
         #raises(RuntimeError, list, it)
 
+    def test_bytes_to_object(self):
+        d = {b'a': 'b'}
+        d[object()] = None
+        assert b'a' in list(d)
 
-class FakeWrapper(object):
+
+class FakeString(str):
+
     hash_count = 0
+
     def unwrap(self, space):
         self.unwrapped = True
         return str(self)
@@ -1028,11 +1032,18 @@
         self.hash_count += 1
         return str.__hash__(self)
 
-class FakeString(FakeWrapper, str):
-    pass
+class FakeUnicode(unicode):
 
-class FakeUnicode(FakeWrapper, unicode):
-    pass
+    hash_count = 0
+
+    def unwrap(self, space):
+        self.unwrapped = True
+        return unicode(self)
+
+    def __hash__(self):
+        self.hash_count += 1
+        return unicode.__hash__(self)
+
 
 # the minimal 'space' needed to use a W_DictMultiObject
 class FakeSpace:
@@ -1054,22 +1065,42 @@
         return l
     def newlist_bytes(self, l):
         return l
+    def newlist_unicode(self, l):
+        return l
     DictObjectCls = W_DictMultiObject
     def type(self, w_obj):
         if isinstance(w_obj, FakeString):
             return str
+        if isinstance(w_obj, FakeUnicode):
+            return unicode
         return type(w_obj)
     w_str = str
+    w_unicode = unicode
 
     def str_w(self, string):
+        if isinstance(string, unicode):
+            return string.encode('utf-8')
         assert isinstance(string, str)
         return string
 
+    def bytes_w(self, string):
+        assert isinstance(string, str)
+        return string
+
+    def unicode_w(self, string):
+        assert isinstance(string, unicode)
+        return string
+
     def int_w(self, integer, allow_conversion=True):
         assert isinstance(integer, int)
         return integer
 
     def wrap(self, obj):
+        if isinstance(obj, str):
+            return obj.decode('ascii')
+        return obj
+
+    def wrapbytes(self, obj):
         return obj
 
     def isinstance_w(self, obj, klass):
@@ -1144,13 +1175,18 @@
             assert value == d.descr_getitem(self.space, key)
 
 class BaseTestRDictImplementation:
+    FakeString = FakeUnicode
+    _str_devolves = False
 
     def setup_method(self,method):
         self.fakespace = FakeSpace()
-        self.string = self.fakespace.wrap("fish")
-        self.string2 = self.fakespace.wrap("fish2")
+        self.string = self.wrapstrorunicode("fish")
+        self.string2 = self.wrapstrorunicode("fish2")
         self.impl = self.get_impl()
 
+    def wrapstrorunicode(self, obj):
+        return self.fakespace.wrap(obj)
+
     def get_impl(self):
         strategy = self.StrategyClass(self.fakespace)
         storage = strategy.get_empty_storage()
@@ -1178,21 +1214,22 @@
         else:
             assert a == self.string2
             assert b == 2000
-            assert self.impl.getitem_str(self.string) == 1000
+            if not self._str_devolves:
+                result = self.impl.getitem_str(self.string)
+            else:
+                result = self.impl.getitem(self.string)
+            assert result == 1000
         self.check_not_devolved()
 
     def test_setitem(self):
         self.impl.setitem(self.string, 1000)
         assert self.impl.length() == 1
         assert self.impl.getitem(self.string) == 1000
-        assert self.impl.getitem_str(self.string) == 1000
-        self.check_not_devolved()
-
-    def test_setitem_str(self):
-        self.impl.setitem_str(self.fakespace.str_w(self.string), 1000)
-        assert self.impl.length() == 1
-        assert self.impl.getitem(self.string) == 1000
-        assert self.impl.getitem_str(self.string) == 1000
+        if not self._str_devolves:
+            result = self.impl.getitem_str(self.string)
+        else:
+            result = self.impl.getitem(self.string)
+        assert result == 1000
         self.check_not_devolved()
 
     def test_delitem(self):
@@ -1256,14 +1293,14 @@
     def test_setdefault_fast(self):
         on_pypy = "__pypy__" in sys.builtin_module_names
         impl = self.impl
-        key = FakeString(self.string)
+        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):
@@ -1296,20 +1333,34 @@
         assert w_key not in d.w_keys()
         assert F() not in d.w_keys()
 
-class TestBytesDictImplementation(BaseTestRDictImplementation):
-    StrategyClass = BytesDictStrategy
+class TestUnicodeDictImplementation(BaseTestRDictImplementation):
+    StrategyClass = UnicodeDictStrategy
 
     def test_str_shortcut(self):
         self.fill_impl()
-        s = FakeString(self.string)
+        s = self.FakeString(self.string)
         assert self.impl.getitem(s) == 1000
         assert s.unwrapped
 
     def test_view_as_kwargs(self):
-        py.test.py3k_skip("XXX: strategies are currently broken")
         self.fill_impl()
         assert self.fakespace.view_as_kwargs(self.impl) == (["fish", "fish2"], [1000, 2000])
 
+    def test_setitem_str(self):
+        self.impl.setitem_str(self.fakespace.str_w(self.string), 1000)
+        assert self.impl.length() == 1
+        assert self.impl.getitem(self.string) == 1000
+        assert self.impl.getitem_str(self.string) == 1000
+        self.check_not_devolved()
+
+class TestBytesDictImplementation(BaseTestRDictImplementation):
+    StrategyClass = BytesDictStrategy
+    FakeString = FakeString
+    _str_devolves = True
+
+    def wrapstrorunicode(self, obj):
+        return self.fakespace.wrapbytes(obj)
+
 
 class BaseTestDevolvedDictImplementation(BaseTestRDictImplementation):
     def fill_impl(self):
@@ -1319,13 +1370,12 @@
     def check_not_devolved(self):
         pass
 
-class TestDevolvedBytesDictImplementation(BaseTestDevolvedDictImplementation):
-    StrategyClass = BytesDictStrategy
+class TestDevolvedUnicodeDictImplementation(BaseTestDevolvedDictImplementation):
+    StrategyClass = UnicodeDictStrategy
 
 
 def test_module_uses_strdict():
-    py.test.py3k_skip("XXX: strategies are currently broken")
     fakespace = FakeSpace()
     d = fakespace.newdict(module=True)
-    assert type(d.strategy) is BytesDictStrategy
+    assert type(d.strategy) is UnicodeDictStrategy
 
diff --git a/pypy/objspace/std/test/test_identitydict.py b/pypy/objspace/std/test/test_identitydict.py
--- a/pypy/objspace/std/test/test_identitydict.py
+++ b/pypy/objspace/std/test/test_identitydict.py
@@ -1,8 +1,6 @@
 import py
 from pypy.interpreter.gateway import interp2app
 
-py.test.py3k_skip("XXX: strategies are currently broken")
-
 class AppTestComparesByIdentity:
     spaceconfig = {"objspace.std.withidentitydict": True}
 
diff --git a/pypy/objspace/std/test/test_kwargsdict.py b/pypy/objspace/std/test/test_kwargsdict.py
--- a/pypy/objspace/std/test/test_kwargsdict.py
+++ b/pypy/objspace/std/test/test_kwargsdict.py
@@ -1,3 +1,4 @@
+# encoding: utf-8
 import py
 from pypy.objspace.std.test.test_dictmultiobject import FakeSpace, W_DictMultiObject
 from pypy.objspace.std.kwargsdict import *
@@ -73,7 +74,7 @@
     for i in range(100):
         assert d.setitem_str("d%s" % i, 4) is None
     assert d.strategy is not strategy
-    assert "BytesDictStrategy" == d.strategy.__class__.__name__
+    assert "UnicodeDictStrategy" == d.strategy.__class__.__name__
 
 def test_keys_doesnt_wrap():
     space = FakeSpace()
@@ -133,7 +134,6 @@
         return r[r.find("(") + 1: r.find(")")]
 
     def test_create(self):
-        py3k_skip("need UnicodeDictStrategy to work in py3k")
         def f(**args):
             return args
         d = f(a=1)
@@ -149,7 +149,6 @@
         assert sorted(f(a=2, b=3).values()) == [2, 3]
 
     def test_setdefault(self):
-        py3k_skip("XXX: strategies are currently broken")
         def f(**args):
             return args
         d = f(a=1, b=2)
@@ -161,3 +160,23 @@
         assert a == 3
         assert "KwargsDictStrategy" in self.get_strategy(d)
 
+    def test_unicode(self):
+        """
+        def f(**kwargs):
+            return kwargs
+
+        d = f(λ=True)
+        assert list(d) == ['λ']
+        assert next(iter(d)) == 'λ'
+        assert "KwargsDictStrategy" in self.get_strategy(d)
+
+        d['foo'] = 'bar'
+        assert sorted(d) == ['foo', 'λ']
+        assert "KwargsDictStrategy" in self.get_strategy(d)
+
+        d = f(λ=True)
+        o = object()
+        d[o] = 'baz'
+        assert set(d) == set(['λ', o])
+        assert "ObjectDictStrategy" in self.get_strategy(d)
+        """
diff --git a/pypy/objspace/std/test/test_listobject.py b/pypy/objspace/std/test/test_listobject.py
--- a/pypy/objspace/std/test/test_listobject.py
+++ b/pypy/objspace/std/test/test_listobject.py
@@ -402,7 +402,6 @@
                            self.space.w_True)
 
     def test_sizehint(self):
-        py.test.py3k_skip("XXX: strategies are currently broken")
         space = self.space
         w_l = space.newlist([], sizehint=10)
         assert isinstance(w_l.strategy, SizeListStrategy)
@@ -419,7 +418,6 @@
         assert w_lst.strategy.sizehint == 13
 
     def test_find_fast_on_intlist(self, monkeypatch):
-        py.test.py3k_skip("XXX: strategies are currently broken")
         monkeypatch.setattr(self.space, "eq_w", None)
         w = self.space.wrap
         intlist = W_ListObject(self.space, [w(1),w(2),w(3),w(4),w(5),w(6),w(7)])
diff --git a/pypy/objspace/std/test/test_liststrategies.py b/pypy/objspace/std/test/test_liststrategies.py
--- a/pypy/objspace/std/test/test_liststrategies.py
+++ b/pypy/objspace/std/test/test_liststrategies.py
@@ -1,4 +1,3 @@
-import py
 import sys
 from pypy.objspace.std.listobject import (
     W_ListObject, EmptyListStrategy, ObjectListStrategy, IntegerListStrategy,
@@ -7,7 +6,6 @@
 from pypy.objspace.std import listobject
 from pypy.objspace.std.test.test_listobject import TestW_ListObject
 
-py.test.py3k_skip("XXX: strategies are currently broken")
 
 class TestW_ListStrategies(TestW_ListObject):
     def test_check_strategy(self):
@@ -186,6 +184,7 @@
     def test_setslice(self):
         space = self.space
         w = space.wrap
+        wb = space.wrapbytes
 
         l = W_ListObject(space, [])
         assert isinstance(l.strategy, EmptyListStrategy)
@@ -579,9 +578,11 @@
         assert not self.space.eq_w(l1, l2)
 
     def test_weird_rangelist_bug(self):
-        l = make_range_list(self.space, 1, 1, 3)
+        space = self.space
+        l = make_range_list(space, 1, 1, 3)
         # should not raise
-        assert l.descr_getslice(self.space, self.space.wrap(15), self.space.wrap(2222)).strategy == self.space.fromcache(EmptyListStrategy)
+        w_slice = space.newslice(space.wrap(15), space.wrap(2222), space.wrap(1))
+        assert l.descr_getitem(space, w_slice).strategy == space.fromcache(EmptyListStrategy)
 
     def test_add_to_rangelist(self):
         l1 = make_range_list(self.space, 1, 1, 3)
@@ -642,13 +643,13 @@
 
     def test_string_uses_newlist_bytes(self):
         space = self.space
-        w_s = space.wrap("a b c")
+        w_s = space.wrapbytes("a b c")
         space.newlist = None
         try:
             w_l = space.call_method(w_s, "split")
-            w_l2 = space.call_method(w_s, "split", space.wrap(" "))
+            w_l2 = space.call_method(w_s, "split", space.wrapbytes(" "))
             w_l3 = space.call_method(w_s, "rsplit")
-            w_l4 = space.call_method(w_s, "rsplit", space.wrap(" "))
+            w_l4 = space.call_method(w_s, "rsplit", space.wrapbytes(" "))
         finally:
             del space.newlist
         assert space.listview_bytes(w_l) == ["a", "b", "c"]
@@ -680,8 +681,6 @@
         assert space.unwrap(w_res) == 3
 
     def test_create_list_from_set(self):
-        # this test fails because of the "w_set.iter = None" line below
-        py.test.py3k_skip("missing the correct list strategy")
         from pypy.objspace.std.setobject import W_SetObject
         from pypy.objspace.std.setobject import _initialize_set
 
diff --git a/pypy/objspace/std/test/test_setobject.py b/pypy/objspace/std/test/test_setobject.py
--- a/pypy/objspace/std/test/test_setobject.py
+++ b/pypy/objspace/std/test/test_setobject.py
@@ -84,12 +84,12 @@
         assert space.is_true(self.space.eq(result, W_SetObject(space, self.space.wrap(""))))
 
     def test_create_set_from_list(self):
-        py.test.py3k_skip("XXX: strategies are currently broken")
         from pypy.interpreter.baseobjspace import W_Root
         from pypy.objspace.std.setobject import BytesSetStrategy, ObjectSetStrategy, UnicodeSetStrategy
         from pypy.objspace.std.floatobject import W_FloatObject
 
         w = self.space.wrap
+        wb = self.space.wrapbytes
         intstr = self.space.fromcache(IntegerSetStrategy)
         tmp_func = intstr.get_storage_from_list
         # test if get_storage_from_list is no longer used
@@ -101,10 +101,10 @@
         assert w_set.strategy is intstr
         assert intstr.unerase(w_set.sstorage) == {1:None, 2:None, 3:None}
 
-        w_list = W_ListObject(self.space, [w("1"), w("2"), w("3")])
+        w_list = W_ListObject(self.space, [wb("1"), wb("2"), wb("3")])
         w_set = W_SetObject(self.space)
         _initialize_set(self.space, w_set, w_list)
-        assert w_set.strategy is self.space.fromcache(UnicodeSetStrategy)
+        assert w_set.strategy is self.space.fromcache(BytesSetStrategy)
         assert w_set.strategy.unerase(w_set.sstorage) == {"1":None, "2":None, "3":None}
 
         w_list = self.space.iter(W_ListObject(self.space, [w(u"1"), w(u"2"), w(u"3")]))
@@ -131,13 +131,13 @@
         intstr.get_storage_from_list = tmp_func
 
     def test_listview_bytes_int_on_set(self):
-        py.test.py3k_skip("XXX: strategies are currently broken")
         w = self.space.wrap
+        wb = self.space.wrapbytes
 
         w_a = W_SetObject(self.space)
-        _initialize_set(self.space, w_a, w("abcdefg"))
-        assert sorted(self.space.listview_bytes(w_a)) == list("abcdefg")
-        assert self.space.listview_int(w_a) is None
+        _initialize_set(self.space, w_a, wb("abcdefg"))
+        assert sorted(self.space.listview_int(w_a)) == [97, 98, 99, 100, 101, 102, 103]
+        assert self.space.listview_bytes(w_a) is None
 
         w_b = W_SetObject(self.space)
         _initialize_set(self.space, w_b, self.space.newlist([w(1),w(2),w(3),w(4),w(5)]))
@@ -1006,6 +1006,13 @@
         # gives us 1, but 1 is not in the set any longer.
         raises(RuntimeError, list, it)
 
+    def test_iter_bytes_strategy(self):
+        l = [b'a', b'b']
+        s = set(l)
+        n = next(iter(s))
+        assert type(n) is bytes
+        assert n in l
+
     def test_unicodestrategy(self):
         s = 'àèìòù'
         myset = set([s])
diff --git a/pypy/objspace/std/test/test_setstrategies.py b/pypy/objspace/std/test/test_setstrategies.py
--- a/pypy/objspace/std/test/test_setstrategies.py
+++ b/pypy/objspace/std/test/test_setstrategies.py
@@ -5,9 +5,6 @@
     UnicodeIteratorImplementation, UnicodeSetStrategy)
 from pypy.objspace.std.listobject import W_ListObject
 
-import py
-py.test.py3k_skip("XXX: strategies are currently broken")
-
 class TestW_SetStrategies:
 
     def wrapped(self, l, bytes=False):


More information about the pypy-commit mailing list