[pypy-commit] pypy py3k-fix-strategies: adapt disabled list strats
pjenvey
noreply at buildbot.pypy.org
Fri Apr 18 02:43:12 CEST 2014
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k-fix-strategies
Changeset: r70738:83e84e9c47fc
Date: 2014-04-17 17:41 -0700
http://bitbucket.org/pypy/pypy/changeset/83e84e9c47fc/
Log: adapt disabled list strats
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
@@ -401,8 +401,9 @@
def buffer_w(w_self, space):
return StringBuffer(w_self._value)
- def listview_bytes(self):
- return _create_list_from_bytes(self._value)
+ # XXX: could provide listview_int
+ #def listview_bytes(self):
+ # return _create_list_from_bytes(self._value)
def ord(self, space):
if len(self._value) != 1:
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
@@ -81,13 +81,11 @@
# 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 +164,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 +872,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:
@@ -1778,7 +1775,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/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)
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
@@ -186,6 +186,7 @@
def test_setslice(self):
space = self.space
w = space.wrap
+ wb = space.wrapbytes
l = W_ListObject(space, [])
assert isinstance(l.strategy, EmptyListStrategy)
@@ -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"]
More information about the pypy-commit
mailing list