[pypy-commit] pypy default: start adding missing abstract methods

cfbolz pypy.commits at gmail.com
Mon May 21 10:04:00 EDT 2018


Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch: 
Changeset: r94627:bf0a01ba0389
Date: 2018-05-17 23:05 +0200
http://bitbucket.org/pypy/pypy/changeset/bf0a01ba0389/

Log:	start adding missing abstract methods

diff --git a/pypy/interpreter/astcompiler/ast.py b/pypy/interpreter/astcompiler/ast.py
--- a/pypy/interpreter/astcompiler/ast.py
+++ b/pypy/interpreter/astcompiler/ast.py
@@ -39,6 +39,9 @@
     def mutate_over(self, visitor):
         raise AssertionError("mutate_over() implementation not provided")
 
+    def to_object(self, space):
+        raise NotImplementedError("abstract base class")
+
 
 class NodeVisitorNotImplemented(Exception):
     pass
diff --git a/pypy/interpreter/astcompiler/tools/asdl_py.py b/pypy/interpreter/astcompiler/tools/asdl_py.py
--- a/pypy/interpreter/astcompiler/tools/asdl_py.py
+++ b/pypy/interpreter/astcompiler/tools/asdl_py.py
@@ -435,6 +435,9 @@
     def mutate_over(self, visitor):
         raise AssertionError("mutate_over() implementation not provided")
 
+    def to_object(self, space):
+        raise NotImplementedError("abstract base class")
+
 
 class NodeVisitorNotImplemented(Exception):
     pass
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -33,6 +33,7 @@
     __slots__ = ('__weakref__',)
     _must_be_light_finalizer_ = True
     user_overridden_class = False
+    _settled_ = True
 
     def getdict(self, space):
         return None
@@ -197,6 +198,8 @@
     # hooks that the mapdict implementations needs:
     def _get_mapdict_map(self):
         return None
+    def _mapdict_init_empty(self, terminator):
+        return None
     def _set_mapdict_map(self, map):
         raise NotImplementedError
     def _mapdict_read_storage(self, index):
@@ -913,9 +916,11 @@
         """Unpack an iterable into a real (interpreter-level) list.
 
         Raise an OperationError(w_ValueError) if the length is wrong."""
+        from pypy.interpreter.generator import GeneratorIterator
         w_iterator = self.iter(w_iterable)
         if expected_length == -1:
             if self.is_generator(w_iterator):
+                assert isinstance(w_iterator, GeneratorIterator)
                 # special hack for speed
                 lst_w = []
                 w_iterator.unpack_into(lst_w)
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
@@ -301,6 +301,7 @@
         """
         strategy = self.get_strategy()
         strategy.move_to_end(self, w_key, last_flag)
+            # XXX this should be in the default move_to_end method!
 
     def nondescr_popitem_first(self, space):
         """Not exposed directly to app-level, but via __pypy__.popitem_first().
@@ -498,6 +499,9 @@
     def get_empty_storage(self):
         raise NotImplementedError
 
+    def switch_to_object_strategy(self, w_dict):
+        raise NotImplementedError
+
     @jit.look_inside_iff(lambda self, w_dict:
                          w_dict_unrolling_heuristic(w_dict))
     def w_keys(self, w_dict):
@@ -584,6 +588,36 @@
     def prepare_update(self, w_dict, num_extra):
         pass
 
+    def length(self, w_dict):
+        raise NotImplementedError
+
+    def getitem(self, w_dict, w_key):
+        raise NotImplementedError
+
+    def getitem_str(self, w_dict, key):
+        raise NotImplementedError
+
+    def setitem(self, w_dict, w_key, w_value):
+        raise NotImplementedError
+
+    def setitem_str(self, w_dict, key, w_value):
+        raise NotImplementedError
+
+    def delitem(self, w_dict, w_key):
+        raise NotImplementedError
+
+    def setdefault(self, w_dict, w_key, w_default):
+        raise NotImplementedError
+
+    def iterkeys(self, w_dict):
+        raise NotImplementedError
+
+    def itervalues(self, w_dict):
+        raise NotImplementedError
+
+    def iteritems(self, w_dict):
+        raise NotImplementedError
+
     def move_to_end(self, w_dict, w_key, last_flag):
         # fall-back
         w_value = w_dict.getitem(w_key)
@@ -807,12 +841,22 @@
 class BaseKeyIterator(BaseIteratorImplementation):
     next_key = _new_next('key')
 
+    def next_key_entry(self):
+        raise NotImplementedError
+
+
 class BaseValueIterator(BaseIteratorImplementation):
     next_value = _new_next('value')
 
+    def next_value_entry(self):
+        raise NotImplementedError
+
 class BaseItemIterator(BaseIteratorImplementation):
     next_item = _new_next('item')
 
+    def next_item_entry(self):
+        raise NotImplementedError
+
 
 def create_iterator_classes(dictimpl):
     if not hasattr(dictimpl, 'wrapkey'):
@@ -1447,6 +1491,7 @@
 class W_DictMultiIterKeysObject(W_BaseDictMultiIterObject):
     def descr_next(self, space):
         iteratorimplementation = self.iteratorimplementation
+        assert isinstance(iteratorimplementation, BaseKeyIterator)
         w_key = iteratorimplementation.next_key()
         if w_key is not None:
             return w_key
@@ -1455,6 +1500,7 @@
 class W_DictMultiIterValuesObject(W_BaseDictMultiIterObject):
     def descr_next(self, space):
         iteratorimplementation = self.iteratorimplementation
+        assert isinstance(iteratorimplementation, BaseValueIterator)
         w_value = iteratorimplementation.next_value()
         if w_value is not None:
             return w_value
@@ -1463,6 +1509,7 @@
 class W_DictMultiIterItemsObject(W_BaseDictMultiIterObject):
     def descr_next(self, space):
         iteratorimplementation = self.iteratorimplementation
+        assert isinstance(iteratorimplementation, BaseItemIterator)
         w_key, w_value = iteratorimplementation.next_item()
         if w_key is not None:
             return space.newtuple([w_key, w_value])
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
@@ -808,6 +808,9 @@
     def getitems(self, w_list):
         return self.getitems_copy(w_list)
 
+    def getitems_fixedsize(self, w_list):
+        raise NotImplementedError
+
     def getitems_copy(self, w_list):
         raise NotImplementedError
 
@@ -856,11 +859,13 @@
         raise NotImplementedError
 
     def extend(self, w_list, w_any):
+        from pypy.interpreter.generator import GeneratorIterator
         space = self.space
         if type(w_any) is W_ListObject or (isinstance(w_any, W_ListObject) and
                                            space._uses_list_iter(w_any)):
             self._extend_from_list(w_list, w_any)
         elif space.is_generator(w_any):
+            assert isinstance(w_any, GeneratorIterator)
             w_any.unpack_into_w(w_list)
         else:
             self._extend_from_iterable(w_list, w_any)


More information about the pypy-commit mailing list