Author: Armin Rigo <[email protected]>
Branch:
Changeset: r84136:b76bb5e1d3cf
Date: 2016-05-02 19:48 +0200
http://bitbucket.org/pypy/pypy/changeset/b76bb5e1d3cf/
Log: merge heads
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
@@ -703,10 +703,10 @@
EMPTY = None, None
def next(self):
- if self.dictimplementation is None:
+ if self.w_dict is None:
return EMPTY
space = self.space
- if self.len != self.dictimplementation.length():
+ if self.len != self.w_dict.length():
self.len = -1 # Make this error state sticky
raise oefmt(space.w_RuntimeError,
"dictionary changed size during iteration")
@@ -715,7 +715,7 @@
if self.pos < self.len:
result = getattr(self, 'next_' + TP + '_entry')()
self.pos += 1
- if self.strategy is self.dictimplementation.get_strategy():
+ if self.strategy is self.w_dict.get_strategy():
return result # common case
else:
# waaa, obscure case: the strategy changed, but not the
@@ -725,28 +725,28 @@
if TP == 'key' or TP == 'value':
return result
w_key = result[0]
- w_value = self.dictimplementation.getitem(w_key)
+ w_value = self.w_dict.getitem(w_key)
if w_value is None:
self.len = -1 # Make this error state sticky
raise oefmt(space.w_RuntimeError,
"dictionary changed during iteration")
return (w_key, w_value)
# no more entries
- self.dictimplementation = None
+ self.w_dict = None
return EMPTY
return func_with_new_name(next, 'next_' + TP)
class BaseIteratorImplementation(object):
- def __init__(self, space, strategy, implementation):
+ def __init__(self, space, strategy, w_dict):
self.space = space
self.strategy = strategy
- self.dictimplementation = implementation
- self.len = implementation.length()
+ self.w_dict = w_dict
+ self.len = w_dict.length()
self.pos = 0
def length(self):
- if self.dictimplementation is not None and self.len != -1:
+ if self.w_dict is not None and self.len != -1:
return self.len - self.pos
return 0
@@ -781,9 +781,9 @@
'setitem_untyped_%s' % dictimpl.__name__)
class IterClassKeys(BaseKeyIterator):
- def __init__(self, space, strategy, impl):
- self.iterator = strategy.getiterkeys(impl)
- BaseIteratorImplementation.__init__(self, space, strategy, impl)
+ def __init__(self, space, strategy, w_dict):
+ self.iterator = strategy.getiterkeys(w_dict)
+ BaseIteratorImplementation.__init__(self, space, strategy, w_dict)
def next_key_entry(self):
for key in self.iterator:
@@ -792,9 +792,9 @@
return None
class IterClassValues(BaseValueIterator):
- def __init__(self, space, strategy, impl):
- self.iterator = strategy.getitervalues(impl)
- BaseIteratorImplementation.__init__(self, space, strategy, impl)
+ def __init__(self, space, strategy, w_dict):
+ self.iterator = strategy.getitervalues(w_dict)
+ BaseIteratorImplementation.__init__(self, space, strategy, w_dict)
def next_value_entry(self):
for value in self.iterator:
@@ -803,9 +803,9 @@
return None
class IterClassItems(BaseItemIterator):
- def __init__(self, space, strategy, impl):
- self.iterator = strategy.getiteritems_with_hash(impl)
- BaseIteratorImplementation.__init__(self, space, strategy, impl)
+ def __init__(self, space, strategy, w_dict):
+ self.iterator = strategy.getiteritems_with_hash(w_dict)
+ BaseIteratorImplementation.__init__(self, space, strategy, w_dict)
def next_item_entry(self):
for key, value, keyhash in self.iterator:
@@ -815,9 +815,9 @@
return None, None
class IterClassReversed(BaseKeyIterator):
- def __init__(self, space, strategy, impl):
- self.iterator = strategy.getiterreversed(impl)
- BaseIteratorImplementation.__init__(self, space, strategy, impl)
+ def __init__(self, space, strategy, w_dict):
+ self.iterator = strategy.getiterreversed(w_dict)
+ BaseIteratorImplementation.__init__(self, space, strategy, w_dict)
def next_key_entry(self):
for key in self.iterator:
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
@@ -833,15 +833,14 @@
obj._set_mapdict_storage_and_map(new_obj.storage, new_obj.map)
class MapDictIteratorKeys(BaseKeyIterator):
- def __init__(self, space, strategy, dictimplementation):
- BaseKeyIterator.__init__(self, space, strategy, dictimplementation)
- w_obj = strategy.unerase(dictimplementation.dstorage)
+ def __init__(self, space, strategy, w_dict):
+ BaseKeyIterator.__init__(self, space, strategy, w_dict)
+ w_obj = strategy.unerase(w_dict.dstorage)
self.w_obj = w_obj
self.orig_map = self.curr_map = w_obj._get_mapdict_map()
def next_key_entry(self):
- implementation = self.dictimplementation
- assert isinstance(implementation.get_strategy(), MapDictStrategy)
+ assert isinstance(self.w_dict.get_strategy(), MapDictStrategy)
if self.orig_map is not self.w_obj._get_mapdict_map():
return None
if self.curr_map:
@@ -855,15 +854,14 @@
class MapDictIteratorValues(BaseValueIterator):
- def __init__(self, space, strategy, dictimplementation):
- BaseValueIterator.__init__(self, space, strategy, dictimplementation)
- w_obj = strategy.unerase(dictimplementation.dstorage)
+ def __init__(self, space, strategy, w_dict):
+ BaseValueIterator.__init__(self, space, strategy, w_dict)
+ w_obj = strategy.unerase(w_dict.dstorage)
self.w_obj = w_obj
self.orig_map = self.curr_map = w_obj._get_mapdict_map()
def next_value_entry(self):
- implementation = self.dictimplementation
- assert isinstance(implementation.get_strategy(), MapDictStrategy)
+ assert isinstance(self.w_dict.get_strategy(), MapDictStrategy)
if self.orig_map is not self.w_obj._get_mapdict_map():
return None
if self.curr_map:
@@ -876,15 +874,14 @@
class MapDictIteratorItems(BaseItemIterator):
- def __init__(self, space, strategy, dictimplementation):
- BaseItemIterator.__init__(self, space, strategy, dictimplementation)
- w_obj = strategy.unerase(dictimplementation.dstorage)
+ def __init__(self, space, strategy, w_dict):
+ BaseItemIterator.__init__(self, space, strategy, w_dict)
+ w_obj = strategy.unerase(w_dict.dstorage)
self.w_obj = w_obj
self.orig_map = self.curr_map = w_obj._get_mapdict_map()
def next_item_entry(self):
- implementation = self.dictimplementation
- assert isinstance(implementation.get_strategy(), MapDictStrategy)
+ assert isinstance(self.w_dict.get_strategy(), MapDictStrategy)
if self.orig_map is not self.w_obj._get_mapdict_map():
return None, None
if self.curr_map:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit