Author: Philip Jenvey <pjen...@underboss.org> Branch: Changeset: r68837:0fb4c2282ffc Date: 2014-01-21 14:25 -0800 http://bitbucket.org/pypy/pypy/changeset/0fb4c2282ffc/
Log: rename the String strategies and {getitems,listview,newlist}_str -> bytes to be consistent with W_BytesObject diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py --- a/pypy/interpreter/baseobjspace.py +++ b/pypy/interpreter/baseobjspace.py @@ -910,7 +910,7 @@ """ return self.unpackiterable(w_iterable, expected_length) - def listview_str(self, w_list): + def listview_bytes(self, w_list): """ Return a list of unwrapped strings out of a list of strings. If the argument is not a list or does not contain only strings, return None. May return None anyway. @@ -944,7 +944,7 @@ """ return (None, None) - def newlist_str(self, list_s): + def newlist_bytes(self, list_s): return self.newlist([self.wrap(s) for s in list_s]) def newlist_unicode(self, list_u): 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 @@ -51,7 +51,9 @@ l = [1, 2, 3] assert list_strategy(l) == "int" l = ["a", "b", "c"] - assert list_strategy(l) == "str" + assert list_strategy(l) == "bytes" + l = [u"a", u"b", u"c"] + assert list_strategy(l) == "unicode" l = [1.1, 2.2, 3.3] assert list_strategy(l) == "float" l = range(3) diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py --- a/pypy/module/cpyext/test/test_cpyext.py +++ b/pypy/module/cpyext/test/test_cpyext.py @@ -213,12 +213,14 @@ Build an extension module linked against the cpyext api library. """ if not space.is_none(w_separate_module_files): - separate_module_files = space.listview_str(w_separate_module_files) + separate_module_files = space.listview_bytes( + w_separate_module_files) assert separate_module_files is not None else: separate_module_files = [] if not space.is_none(w_separate_module_sources): - separate_module_sources = space.listview_str(w_separate_module_sources) + separate_module_sources = space.listview_bytes( + w_separate_module_sources) assert separate_module_sources is not None else: separate_module_sources = [] 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 @@ -441,8 +441,8 @@ def str_w(self, space): return self._value - def listview_str(self): - return _create_list_from_string(self._value) + def listview_bytes(self): + return _create_list_from_bytes(self._value) def ord(self, space): if len(self._value) != 1: @@ -518,7 +518,7 @@ _title = _upper def _newlist_unwrapped(self, space, lst): - return space.newlist_str(lst) + return space.newlist_bytes(lst) @staticmethod @unwrap_spec(w_object = WrappedDefault("")) @@ -725,9 +725,9 @@ return tformat.formatter_field_name_split() -def _create_list_from_string(value): +def _create_list_from_bytes(value): # need this helper function to allow the jit to look inside and inline - # listview_str + # listview_bytes return [s for s in value] W_BytesObject.EMPTY = W_BytesObject('') 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 @@ -127,7 +127,7 @@ def w_keys(self, w_dict): space = self.space l = self.unerase(w_dict.dstorage).keys() - return space.newlist_str(l) + return space.newlist_bytes(l) def values(self, w_dict): iterator = self.unerase(w_dict.dstorage).itervalues 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 @@ -58,7 +58,7 @@ strategy = space.fromcache(MapDictStrategy) elif instance or strdict or module: assert w_type is None - strategy = space.fromcache(StringDictStrategy) + strategy = space.fromcache(BytesDictStrategy) elif kwargs: assert w_type is None from pypy.objspace.std.kwargsdict import EmptyKwargsDictStrategy @@ -117,9 +117,9 @@ if space.is_w(w_type, space.w_dict): w_dict = W_DictMultiObject.allocate_and_init_instance(space, w_type) - strlist = space.listview_str(w_keys) - if strlist is not None: - for key in strlist: + byteslist = space.listview_bytes(w_keys) + if byteslist is not None: + for key in byteslist: w_dict.setitem_str(key, w_fill) else: for w_key in space.listview(w_keys): @@ -333,7 +333,7 @@ popitem delitem clear \ length w_keys values items \ iterkeys itervalues iteritems \ - listview_str listview_unicode listview_int \ + listview_bytes listview_unicode listview_int \ view_as_kwargs".split() def make_method(method): @@ -482,7 +482,7 @@ w_dict.strategy = strategy w_dict.dstorage = storage - def listview_str(self, w_dict): + def listview_bytes(self, w_dict): return None def listview_unicode(self, w_dict): @@ -506,7 +506,7 @@ def switch_to_correct_strategy(self, w_dict, w_key): withidentitydict = self.space.config.objspace.std.withidentitydict if type(w_key) is self.space.StringObjectCls: - self.switch_to_string_strategy(w_dict) + self.switch_to_bytes_strategy(w_dict) return elif type(w_key) is self.space.UnicodeObjectCls: self.switch_to_unicode_strategy(w_dict) @@ -519,8 +519,8 @@ else: self.switch_to_object_strategy(w_dict) - def switch_to_string_strategy(self, w_dict): - strategy = self.space.fromcache(StringDictStrategy) + def switch_to_bytes_strategy(self, w_dict): + strategy = self.space.fromcache(BytesDictStrategy) storage = strategy.get_empty_storage() w_dict.strategy = strategy w_dict.dstorage = storage @@ -572,7 +572,7 @@ w_dict.setitem(w_key, w_value) def setitem_str(self, w_dict, key, w_value): - self.switch_to_string_strategy(w_dict) + self.switch_to_bytes_strategy(w_dict) w_dict.setitem_str(key, w_value) def delitem(self, w_dict, w_key): @@ -874,8 +874,8 @@ create_iterator_classes(ObjectDictStrategy) -class StringDictStrategy(AbstractTypedStrategy, DictStrategy): - erase, unerase = rerased.new_erasing_pair("string") +class BytesDictStrategy(AbstractTypedStrategy, DictStrategy): + erase, unerase = rerased.new_erasing_pair("bytes") erase = staticmethod(erase) unerase = staticmethod(unerase) @@ -913,11 +913,11 @@ assert key is not None return self.unerase(w_dict.dstorage).get(key, None) - def listview_str(self, w_dict): + def listview_bytes(self, w_dict): return self.unerase(w_dict.dstorage).keys() def w_keys(self, w_dict): - return self.space.newlist_str(self.listview_str(w_dict)) + return self.space.newlist_bytes(self.listview_bytes(w_dict)) def wrapkey(space, key): return space.wrap(key) @@ -935,7 +935,7 @@ i += 1 return keys, values -create_iterator_classes(StringDictStrategy) +create_iterator_classes(BytesDictStrategy) class UnicodeDictStrategy(AbstractTypedStrategy, DictStrategy): @@ -961,7 +961,7 @@ def _never_equal_to(self, w_lookup_type): return _never_equal_to_string(self.space, w_lookup_type) - # we should implement the same shortcuts as we do for StringDictStrategy + # 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 @@ -983,7 +983,7 @@ return self.unerase(w_dict.dstorage).keys() ## def w_keys(self, w_dict): - ## return self.space.newlist_str(self.listview_str(w_dict)) + ## return self.space.newlist_bytes(self.listview_bytes(w_dict)) def wrapkey(space, key): return space.wrap(key) diff --git a/pypy/objspace/std/dictproxyobject.py b/pypy/objspace/std/dictproxyobject.py --- a/pypy/objspace/std/dictproxyobject.py +++ b/pypy/objspace/std/dictproxyobject.py @@ -84,7 +84,7 @@ def w_keys(self, w_dict): space = self.space - return space.newlist_str(self.unerase(w_dict.dstorage).dict_w.keys()) + return space.newlist_bytes(self.unerase(w_dict.dstorage).dict_w.keys()) def values(self, w_dict): return [unwrap_cell(self.space, w_value) for w_value in self.unerase(w_dict.dstorage).dict_w.itervalues()] 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 @@ -2,15 +2,13 @@ ## dict strategy (see dictmultiobject.py) from rpython.rlib import rerased, jit -from pypy.objspace.std.dictmultiobject import (DictStrategy, - create_iterator_classes, - EmptyDictStrategy, - ObjectDictStrategy, - StringDictStrategy) +from pypy.objspace.std.dictmultiobject import ( + BytesDictStrategy, DictStrategy, EmptyDictStrategy, ObjectDictStrategy, + create_iterator_classes) class EmptyKwargsDictStrategy(EmptyDictStrategy): - def switch_to_string_strategy(self, w_dict): + def switch_to_bytes_strategy(self, w_dict): strategy = self.space.fromcache(KwargsDictStrategy) storage = strategy.get_empty_storage() w_dict.strategy = strategy @@ -61,7 +59,7 @@ else: # limit the size so that the linear searches don't become too long if len(keys) >= 16: - self.switch_to_string_strategy(w_dict) + self.switch_to_bytes_strategy(w_dict) w_dict.setitem_str(key, w_value) else: keys.append(key) @@ -111,7 +109,7 @@ def w_keys(self, w_dict): l = self.unerase(w_dict.dstorage)[0] - return self.space.newlist_str(l[:]) + return self.space.newlist_bytes(l[:]) def values(self, w_dict): return self.unerase(w_dict.dstorage)[1][:] # to make non-resizable @@ -142,8 +140,8 @@ w_dict.strategy = strategy w_dict.dstorage = strategy.erase(d_new) - def switch_to_string_strategy(self, w_dict): - strategy = self.space.fromcache(StringDictStrategy) + def switch_to_bytes_strategy(self, w_dict): + strategy = self.space.fromcache(BytesDictStrategy) keys, values_w = self.unerase(w_dict.dstorage) storage = strategy.get_empty_storage() d_new = strategy.unerase(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 @@ -81,7 +81,7 @@ if not type(w_obj) is W_BytesObject: break else: - return space.fromcache(StringListStrategy) + return space.fromcache(BytesListStrategy) # check for unicode for w_obj in list_w: @@ -162,8 +162,8 @@ return self @staticmethod - def newlist_str(space, list_s): - strategy = space.fromcache(StringListStrategy) + def newlist_bytes(space, list_s): + strategy = space.fromcache(BytesListStrategy) storage = strategy.erase(list_s) return W_ListObject.from_storage_and_strategy(space, storage, strategy) @@ -278,10 +278,10 @@ ObjectListStrategy.""" return self.strategy.getitems_copy(self) - def getitems_str(self): + def getitems_bytes(self): """Return the items in the list as unwrapped strings. If the list does not use the list strategy, return None.""" - return self.strategy.getitems_str(self) + return self.strategy.getitems_bytes(self) def getitems_unicode(self): """Return the items in the list as unwrapped unicodes. If the list does @@ -753,7 +753,7 @@ def getitems_copy(self, w_list): raise NotImplementedError - def getitems_str(self, w_list): + def getitems_bytes(self, w_list): return None def getitems_unicode(self, w_list): @@ -897,7 +897,7 @@ if type(w_item) is W_IntObject: strategy = self.space.fromcache(IntegerListStrategy) elif type(w_item) is W_BytesObject: - strategy = self.space.fromcache(StringListStrategy) + strategy = self.space.fromcache(BytesListStrategy) elif type(w_item) is W_UnicodeObject: strategy = self.space.fromcache(UnicodeListStrategy) elif type(w_item) is W_FloatObject: @@ -962,11 +962,11 @@ w_list.lstorage = strategy.erase(floatlist) return - strlist = space.listview_str(w_iterable) - if strlist is not None: - w_list.strategy = strategy = space.fromcache(StringListStrategy) + byteslist = space.listview_bytes(w_iterable) + if byteslist is not None: + w_list.strategy = strategy = space.fromcache(BytesListStrategy) # need to copy because intlist can share with w_iterable - w_list.lstorage = strategy.erase(strlist[:]) + w_list.lstorage = strategy.erase(byteslist[:]) return unilist = space.listview_unicode(w_iterable) @@ -1592,11 +1592,11 @@ return self.unerase(w_list.lstorage) -class StringListStrategy(ListStrategy): +class BytesListStrategy(ListStrategy): import_from_mixin(AbstractUnwrappedStrategy) _none_value = None - _applevel_repr = "str" + _applevel_repr = "bytes" def wrap(self, stringval): return self.space.wrap(stringval) @@ -1604,7 +1604,7 @@ def unwrap(self, w_string): return self.space.str_w(w_string) - erase, unerase = rerased.new_erasing_pair("string") + erase, unerase = rerased.new_erasing_pair("bytes") erase = staticmethod(erase) unerase = staticmethod(unerase) @@ -1612,7 +1612,7 @@ return type(w_obj) is W_BytesObject def list_is_correct_type(self, w_list): - return w_list.strategy is self.space.fromcache(StringListStrategy) + return w_list.strategy is self.space.fromcache(BytesListStrategy) def sort(self, w_list, reverse): l = self.unerase(w_list.lstorage) @@ -1621,7 +1621,7 @@ if reverse: l.reverse() - def getitems_str(self, w_list): + def getitems_bytes(self, w_list): return self.unerase(w_list.lstorage) 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 @@ -700,7 +700,7 @@ self.delitem(w_dict, w_key) return (w_key, w_value) - # XXX could implement a more efficient w_keys based on space.newlist_str + # XXX could implement a more efficient w_keys based on space.newlist_bytes def iterkeys(self, w_dict): return MapDictIteratorKeys(self.space, self, w_dict) 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 @@ -292,8 +292,8 @@ assert not list_w or sizehint == -1 return W_ListObject(self, list_w, sizehint) - def newlist_str(self, list_s): - return W_ListObject.newlist_str(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) @@ -431,19 +431,19 @@ raise self._wrap_expected_length(expected_length, len(t)) return t - def listview_str(self, w_obj): + def listview_bytes(self, w_obj): # note: uses exact type checking for objects with strategies, # and isinstance() for others. See test_listobject.test_uses_custom... if type(w_obj) is W_ListObject: - return w_obj.getitems_str() + return w_obj.getitems_bytes() if type(w_obj) is W_DictMultiObject: - return w_obj.listview_str() + return w_obj.listview_bytes() if type(w_obj) is W_SetObject or type(w_obj) is W_FrozensetObject: - return w_obj.listview_str() + return w_obj.listview_bytes() if isinstance(w_obj, W_BytesObject) and self._uses_no_iter(w_obj): - return w_obj.listview_str() + return w_obj.listview_bytes() if isinstance(w_obj, W_ListObject) and self._uses_list_iter(w_obj): - return w_obj.getitems_str() + return w_obj.getitems_bytes() return None def listview_unicode(self, w_obj): 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 @@ -79,9 +79,9 @@ """ Returns a dict with all elements of the set. Needed only for switching to ObjectSetStrategy. """ return self.strategy.getdict_w(self) - def listview_str(self): + def listview_bytes(self): """ If this is a string set return its contents as a list of uwnrapped strings. Otherwise return None. """ - return self.strategy.listview_str(self) + return self.strategy.listview_bytes(self) def listview_unicode(self): """ If this is a unicode set return its contents as a list of uwnrapped unicodes. Otherwise return None. """ @@ -669,7 +669,7 @@ """ Returns an empty storage (erased) object. Used to initialize an empty set.""" raise NotImplementedError - def listview_str(self, w_set): + def listview_bytes(self, w_set): return None def listview_unicode(self, w_set): @@ -776,7 +776,7 @@ if type(w_key) is W_IntObject: strategy = self.space.fromcache(IntegerSetStrategy) elif type(w_key) is W_BytesObject: - strategy = self.space.fromcache(StringSetStrategy) + strategy = self.space.fromcache(BytesSetStrategy) elif type(w_key) is W_UnicodeObject: strategy = self.space.fromcache(UnicodeSetStrategy) elif self.space.type(w_key).compares_by_identity(): @@ -1196,8 +1196,8 @@ return self.wrap(result[0]) -class StringSetStrategy(AbstractUnwrappedSetStrategy, SetStrategy): - erase, unerase = rerased.new_erasing_pair("string") +class BytesSetStrategy(AbstractUnwrappedSetStrategy, SetStrategy): + erase, unerase = rerased.new_erasing_pair("bytes") erase = staticmethod(erase) unerase = staticmethod(unerase) @@ -1207,7 +1207,7 @@ def get_empty_dict(self): return {} - def listview_str(self, w_set): + def listview_bytes(self, w_set): return self.unerase(w_set.sstorage).keys() def is_correct_type(self, w_key): @@ -1229,7 +1229,7 @@ return self.space.wrap(item) def iter(self, w_set): - return StringIteratorImplementation(self.space, self, w_set) + return BytesIteratorImplementation(self.space, self, w_set) class UnicodeSetStrategy(AbstractUnwrappedSetStrategy, SetStrategy): @@ -1286,7 +1286,7 @@ return type(w_key) is W_IntObject def may_contain_equal_elements(self, strategy): - if strategy is self.space.fromcache(StringSetStrategy): + if strategy is self.space.fromcache(BytesSetStrategy): return False elif strategy is self.space.fromcache(UnicodeSetStrategy): return False @@ -1371,7 +1371,7 @@ return False if strategy is self.space.fromcache(IntegerSetStrategy): return False - if strategy is self.space.fromcache(StringSetStrategy): + if strategy is self.space.fromcache(BytesSetStrategy): return False if strategy is self.space.fromcache(UnicodeSetStrategy): return False @@ -1436,7 +1436,7 @@ return None -class StringIteratorImplementation(IteratorImplementation): +class BytesIteratorImplementation(IteratorImplementation): def __init__(self, space, strategy, w_set): IteratorImplementation.__init__(self, space, strategy, w_set) d = strategy.unerase(w_set.sstorage) @@ -1546,11 +1546,11 @@ w_set.sstorage = w_iterable.get_storage_copy() return - stringlist = space.listview_str(w_iterable) - if stringlist is not None: - strategy = space.fromcache(StringSetStrategy) + byteslist = space.listview_bytes(w_iterable) + if byteslist is not None: + strategy = space.fromcache(BytesSetStrategy) w_set.strategy = strategy - w_set.sstorage = strategy.get_storage_from_unwrapped_list(stringlist) + w_set.sstorage = strategy.get_storage_from_unwrapped_list(byteslist) return unicodelist = space.listview_unicode(w_iterable) @@ -1593,7 +1593,7 @@ if type(w_item) is not W_BytesObject: break else: - w_set.strategy = space.fromcache(StringSetStrategy) + w_set.strategy = space.fromcache(BytesSetStrategy) w_set.sstorage = w_set.strategy.get_storage_from_list(iterable_w) return diff --git a/pypy/objspace/std/stringmethods.py b/pypy/objspace/std/stringmethods.py --- a/pypy/objspace/std/stringmethods.py +++ b/pypy/objspace/std/stringmethods.py @@ -311,7 +311,7 @@ from pypy.objspace.std.unicodeobject import W_UnicodeObject if isinstance(self, W_BytesObject): - l = space.listview_str(w_list) + l = space.listview_bytes(w_list) if l is not None: if len(l) == 1: return space.wrap(l[0]) 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 @@ -80,9 +80,9 @@ w_slice = space.newslice(w(1), w_None, w(2)) assert self.space.eq_w(space.getitem(w_str, w_slice), w('el')) - def test_listview_str(self): + def test_listview_bytes(self): w_str = self.space.wrap('abcd') - assert self.space.listview_str(w_str) == list("abcd") + assert self.space.listview_bytes(w_str) == list("abcd") class AppTestBytesObject: 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 @@ -2,7 +2,7 @@ import py from pypy.objspace.std.dictmultiobject import (W_DictMultiObject, - StringDictStrategy, ObjectDictStrategy) + BytesDictStrategy, ObjectDictStrategy) class TestW_DictObject(object): @@ -134,11 +134,11 @@ assert space.eq_w(w_d.getitem_str("a"), space.w_None) assert space.eq_w(w_d.getitem_str("b"), space.w_None) - def test_listview_str_dict(self): + def test_listview_bytes_dict(self): w = self.space.wrap w_d = self.space.newdict() w_d.initialize_content([(w("a"), w(1)), (w("b"), w(2))]) - assert self.space.listview_str(w_d) == ["a", "b"] + assert self.space.listview_bytes(w_d) == ["a", "b"] def test_listview_unicode_dict(self): w = self.space.wrap @@ -160,7 +160,7 @@ w_l = self.space.call_method(w_d, "keys") assert sorted(self.space.listview_int(w_l)) == [1,2] - # make sure that .keys() calls newlist_str for string dicts + # make sure that .keys() calls newlist_bytes for string dicts def not_allowed(*args): assert False, 'should not be called' monkeypatch.setattr(self.space, 'newlist', not_allowed) @@ -168,7 +168,7 @@ 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") - assert sorted(self.space.listview_str(w_l)) == ["a", "b"] + assert sorted(self.space.listview_bytes(w_l)) == ["a", "b"] # XXX: it would be nice if the test passed without monkeypatch.undo(), # but we need space.newlist_unicode for it @@ -944,7 +944,7 @@ d = {} assert "EmptyDictStrategy" in self.get_strategy(d) d["a"] = 1 - assert "StringDictStrategy" in self.get_strategy(d) + assert "BytesDictStrategy" in self.get_strategy(d) class O(object): pass @@ -952,7 +952,7 @@ d = o.__dict__ = {} assert "EmptyDictStrategy" in self.get_strategy(d) o.a = 1 - assert "StringDictStrategy" in self.get_strategy(d) + assert "BytesDictStrategy" in self.get_strategy(d) def test_empty_to_unicode(self): d = {} @@ -1033,7 +1033,7 @@ eq_w = eq def newlist(self, l): return l - def newlist_str(self, l): + def newlist_bytes(self, l): return l DictObjectCls = W_DictMultiObject def type(self, w_obj): @@ -1275,9 +1275,9 @@ assert "s" not in d.w_keys() assert F() not in d.w_keys() -class TestStrDictImplementation(BaseTestRDictImplementation): - StrategyClass = StringDictStrategy - #ImplementionClass = StrDictImplementation +class TestBytesDictImplementation(BaseTestRDictImplementation): + StrategyClass = BytesDictStrategy + #ImplementionClass = BytesDictImplementation def test_str_shortcut(self): self.fill_impl() @@ -1301,12 +1301,12 @@ def check_not_devolved(self): pass -class TestDevolvedStrDictImplementation(BaseTestDevolvedDictImplementation): - StrategyClass = StringDictStrategy +class TestDevolvedBytesDictImplementation(BaseTestDevolvedDictImplementation): + StrategyClass = BytesDictStrategy def test_module_uses_strdict(): fakespace = FakeSpace() d = fakespace.newdict(module=True) - assert type(d.strategy) is StringDictStrategy + assert type(d.strategy) is BytesDictStrategy 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 @@ -73,7 +73,7 @@ for i in range(100): assert d.setitem_str("d%s" % i, 4) is None assert d.strategy is not strategy - assert "StringDictStrategy" == d.strategy.__class__.__name__ + assert "BytesDictStrategy" == d.strategy.__class__.__name__ def test_keys_doesnt_wrap(): space = FakeSpace() 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,5 +1,5 @@ import sys -from pypy.objspace.std.listobject import W_ListObject, EmptyListStrategy, ObjectListStrategy, IntegerListStrategy, FloatListStrategy, StringListStrategy, RangeListStrategy, make_range_list, UnicodeListStrategy +from pypy.objspace.std.listobject import W_ListObject, EmptyListStrategy, ObjectListStrategy, IntegerListStrategy, FloatListStrategy, BytesListStrategy, RangeListStrategy, make_range_list, UnicodeListStrategy from pypy.objspace.std import listobject from pypy.objspace.std.test.test_listobject import TestW_ListObject @@ -13,7 +13,7 @@ assert isinstance(W_ListObject(space, [w(1),w(2),w(3)]).strategy, IntegerListStrategy) assert isinstance(W_ListObject(space, [w('a'), w('b')]).strategy, - StringListStrategy) + BytesListStrategy) assert isinstance(W_ListObject(space, [w(u'a'), w(u'b')]).strategy, UnicodeListStrategy) assert isinstance(W_ListObject(space, [w(u'a'), w('b')]).strategy, @@ -35,7 +35,7 @@ l = W_ListObject(space, []) assert isinstance(l.strategy, EmptyListStrategy) l.append(w('a')) - assert isinstance(l.strategy, StringListStrategy) + assert isinstance(l.strategy, BytesListStrategy) l = W_ListObject(space, []) assert isinstance(l.strategy, EmptyListStrategy) @@ -59,9 +59,9 @@ def test_string_to_any(self): l = W_ListObject(self.space, [self.space.wrap('a'),self.space.wrap('b'),self.space.wrap('c')]) - assert isinstance(l.strategy, StringListStrategy) + assert isinstance(l.strategy, BytesListStrategy) l.append(self.space.wrap('d')) - assert isinstance(l.strategy, StringListStrategy) + assert isinstance(l.strategy, BytesListStrategy) l.append(self.space.wrap(3)) assert isinstance(l.strategy, ObjectListStrategy) @@ -92,7 +92,7 @@ l.setitem(0, w('d')) assert space.eq_w(l.getitem(0), w('d')) - assert isinstance(l.strategy, StringListStrategy) + assert isinstance(l.strategy, BytesListStrategy) # IntStrategy to ObjectStrategy l = W_ListObject(space, [w(1),w(2),w(3)]) @@ -100,9 +100,9 @@ l.setitem(0, w('d')) assert isinstance(l.strategy, ObjectListStrategy) - # StringStrategy to ObjectStrategy + # BytesStrategy to ObjectStrategy l = W_ListObject(space, [w('a'),w('b'),w('c')]) - assert isinstance(l.strategy, StringListStrategy) + assert isinstance(l.strategy, BytesListStrategy) l.setitem(0, w(2)) assert isinstance(l.strategy, ObjectListStrategy) @@ -127,9 +127,9 @@ l.insert(3, w(4)) assert isinstance(l.strategy, IntegerListStrategy) - # StringStrategy + # BytesStrategy l = W_ListObject(space, [w('a'),w('b'),w('c')]) - assert isinstance(l.strategy, StringListStrategy) + assert isinstance(l.strategy, BytesListStrategy) l.insert(3, w(2)) assert isinstance(l.strategy, ObjectListStrategy) @@ -155,7 +155,7 @@ l = W_ListObject(space, []) assert isinstance(l.strategy, EmptyListStrategy) l.insert(0, w('a')) - assert isinstance(l.strategy, StringListStrategy) + assert isinstance(l.strategy, BytesListStrategy) l = W_ListObject(space, []) assert isinstance(l.strategy, EmptyListStrategy) @@ -207,9 +207,9 @@ l.setslice(0, 1, 2, W_ListObject(space, [w('a'), w('b'), w('c')])) assert isinstance(l.strategy, ObjectListStrategy) - # StringStrategy to ObjectStrategy + # BytesStrategy to ObjectStrategy l = W_ListObject(space, [w('a'), w('b'), w('c')]) - assert isinstance(l.strategy, StringListStrategy) + assert isinstance(l.strategy, BytesListStrategy) l.setslice(0, 1, 2, W_ListObject(space, [w(1), w(2), w(3)])) assert isinstance(l.strategy, ObjectListStrategy) @@ -261,7 +261,7 @@ l = W_ListObject(space, wrapitems(["a","b","c","d","e"])) other = W_ListObject(space, wrapitems(["a", "b", "c"])) keep_other_strategy(l, 0, 2, other.length(), other) - assert l.strategy is space.fromcache(StringListStrategy) + assert l.strategy is space.fromcache(BytesListStrategy) l = W_ListObject(space, wrapitems([u"a",u"b",u"c",u"d",u"e"])) other = W_ListObject(space, wrapitems([u"a", u"b", u"c"])) @@ -330,7 +330,7 @@ empty = W_ListObject(space, []) assert isinstance(empty.strategy, EmptyListStrategy) empty.extend(W_ListObject(space, [w("a"), w("b"), w("c")])) - assert isinstance(empty.strategy, StringListStrategy) + assert isinstance(empty.strategy, BytesListStrategy) empty = W_ListObject(space, []) assert isinstance(empty.strategy, EmptyListStrategy) @@ -514,17 +514,17 @@ def test_unicode(self): l1 = W_ListObject(self.space, [self.space.wrap("eins"), self.space.wrap("zwei")]) - assert isinstance(l1.strategy, StringListStrategy) + assert isinstance(l1.strategy, BytesListStrategy) l2 = W_ListObject(self.space, [self.space.wrap(u"eins"), self.space.wrap(u"zwei")]) assert isinstance(l2.strategy, UnicodeListStrategy) l3 = W_ListObject(self.space, [self.space.wrap("eins"), self.space.wrap(u"zwei")]) assert isinstance(l3.strategy, ObjectListStrategy) - def test_listview_str(self): + def test_listview_bytes(self): space = self.space - assert space.listview_str(space.wrap(1)) == None + assert space.listview_bytes(space.wrap(1)) == None w_l = self.space.newlist([self.space.wrap('a'), self.space.wrap('b')]) - assert space.listview_str(w_l) == ["a", "b"] + assert space.listview_bytes(w_l) == ["a", "b"] def test_listview_unicode(self): space = self.space @@ -532,7 +532,7 @@ w_l = self.space.newlist([self.space.wrap(u'a'), self.space.wrap(u'b')]) assert space.listview_unicode(w_l) == [u"a", u"b"] - def test_string_join_uses_listview_str(self): + def test_string_join_uses_listview_bytes(self): space = self.space w_l = self.space.newlist([self.space.wrap('a'), self.space.wrap('b')]) w_l.getitems = None @@ -556,14 +556,14 @@ w_l.getitems = None assert space.is_w(space.call_method(space.wrap(u" -- "), "join", w_l), w_text) - def test_newlist_str(self): + def test_newlist_bytes(self): space = self.space l = ['a', 'b'] - w_l = self.space.newlist_str(l) - assert isinstance(w_l.strategy, StringListStrategy) - assert space.listview_str(w_l) is l + w_l = self.space.newlist_bytes(l) + assert isinstance(w_l.strategy, BytesListStrategy) + assert space.listview_bytes(w_l) is l - def test_string_uses_newlist_str(self): + def test_string_uses_newlist_bytes(self): space = self.space w_s = space.wrap("a b c") space.newlist = None @@ -574,10 +574,10 @@ w_l4 = space.call_method(w_s, "rsplit", space.wrap(" ")) finally: del space.newlist - assert space.listview_str(w_l) == ["a", "b", "c"] - assert space.listview_str(w_l2) == ["a", "b", "c"] - assert space.listview_str(w_l3) == ["a", "b", "c"] - assert space.listview_str(w_l4) == ["a", "b", "c"] + assert space.listview_bytes(w_l) == ["a", "b", "c"] + assert space.listview_bytes(w_l2) == ["a", "b", "c"] + assert space.listview_bytes(w_l3) == ["a", "b", "c"] + assert space.listview_bytes(w_l4) == ["a", "b", "c"] def test_unicode_uses_newlist_unicode(self): space = self.space @@ -630,10 +630,10 @@ assert space.eq_w(w_l, w_l2) - def test_listview_str_list(self): + def test_listview_bytes_list(self): space = self.space w_l = W_ListObject(space, [space.wrap("a"), space.wrap("b")]) - assert self.space.listview_str(w_l) == ["a", "b"] + assert self.space.listview_bytes(w_l) == ["a", "b"] def test_listview_unicode_list(self): space = self.space 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 @@ -82,7 +82,7 @@ def test_create_set_from_list(self): from pypy.interpreter.baseobjspace import W_Root - from pypy.objspace.std.setobject import ObjectSetStrategy, StringSetStrategy, UnicodeSetStrategy + from pypy.objspace.std.setobject import BytesSetStrategy, ObjectSetStrategy, UnicodeSetStrategy from pypy.objspace.std.floatobject import W_FloatObject w = self.space.wrap @@ -100,7 +100,7 @@ w_list = W_ListObject(self.space, [w("1"), w("2"), w("3")]) w_set = W_SetObject(self.space) _initialize_set(self.space, w_set, w_list) - assert w_set.strategy is self.space.fromcache(StringSetStrategy) + 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")])) @@ -126,18 +126,18 @@ # changed cached object, need to change it back for other tests to pass intstr.get_storage_from_list = tmp_func - def test_listview_str_int_on_set(self): + def test_listview_bytes_int_on_set(self): w = self.space.wrap w_a = W_SetObject(self.space) _initialize_set(self.space, w_a, w("abcdefg")) - assert sorted(self.space.listview_str(w_a)) == list("abcdefg") + assert sorted(self.space.listview_bytes(w_a)) == list("abcdefg") assert self.space.listview_int(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)])) assert sorted(self.space.listview_int(w_b)) == [1,2,3,4,5] - assert self.space.listview_str(w_b) is None + assert self.space.listview_bytes(w_b) is None class AppTestAppSetTest: 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 @@ -1,10 +1,8 @@ from pypy.objspace.std.setobject import W_SetObject -from pypy.objspace.std.setobject import (IntegerSetStrategy, ObjectSetStrategy, - EmptySetStrategy, StringSetStrategy, - UnicodeSetStrategy, - IntegerIteratorImplementation, - StringIteratorImplementation, - UnicodeIteratorImplementation) +from pypy.objspace.std.setobject import ( + BytesIteratorImplementation, BytesSetStrategy, EmptySetStrategy, + IntegerIteratorImplementation, IntegerSetStrategy, ObjectSetStrategy, + UnicodeIteratorImplementation, UnicodeSetStrategy) from pypy.objspace.std.listobject import W_ListObject class TestW_SetStrategies: @@ -26,7 +24,7 @@ assert s.strategy is self.space.fromcache(EmptySetStrategy) s = W_SetObject(self.space, self.wrapped(["a", "b"])) - assert s.strategy is self.space.fromcache(StringSetStrategy) + assert s.strategy is self.space.fromcache(BytesSetStrategy) s = W_SetObject(self.space, self.wrapped([u"a", u"b"])) assert s.strategy is self.space.fromcache(UnicodeSetStrategy) @@ -126,7 +124,7 @@ # s = W_SetObject(space, self.wrapped(["a", "b"])) it = s.iter() - assert isinstance(it, StringIteratorImplementation) + assert isinstance(it, BytesIteratorImplementation) assert space.unwrap(it.next()) == "a" assert space.unwrap(it.next()) == "b" # @@ -142,7 +140,7 @@ assert sorted(space.listview_int(s)) == [1, 2] # s = W_SetObject(space, self.wrapped(["a", "b"])) - assert sorted(space.listview_str(s)) == ["a", "b"] + assert sorted(space.listview_bytes(s)) == ["a", "b"] # s = W_SetObject(space, self.wrapped([u"a", u"b"])) assert sorted(space.listview_unicode(s)) == [u"a", u"b"] _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit