[pypy-commit] pypy hpy: finally fix hpy_universa:test_ztranslation: we need to ensure that the annotator sees some concrete implementation of W_DictMultiObject, else it only sees the base class which is full of abstract methods

antocuni pypy.commits at gmail.com
Mon Dec 2 06:25:08 EST 2019


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: hpy
Changeset: r98214:4aa8318c0c07
Date: 2019-12-02 12:23 +0100
http://bitbucket.org/pypy/pypy/changeset/4aa8318c0c07/

Log:	finally fix hpy_universa:test_ztranslation: we need to ensure that
	the annotator sees some concrete implementation of
	W_DictMultiObject, else it only sees the base class which is full of
	abstract methods

diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -165,8 +165,20 @@
                 w_obj.strategy = ObjectListStrategy(space)
                 list_w = [w_some_obj(), w_some_obj()]
                 w_obj.lstorage = w_obj.strategy.erase(list_w)
+        def attach_dict_strategy():
+            # this is needed for modules which do e.g. "isinstance(w_obj,
+            # W_DictMultiObject)", like hpy_universal. Make sure that the
+            # annotator sees a concrete class, like W_DictObject, else lots of
+            # operations are blocked.
+            from pypy.objspace.std.dictmultiobject import W_DictObject, ObjectDictStrategy
+            space = self
+            strategy = ObjectDictStrategy(space)
+            storage = strategy.get_empty_storage()
+            w_obj = W_DictObject(space, strategy, storage)
+
         self._seen_extras.append(build_slice)
         self._seen_extras.append(attach_list_strategy)
+        self._seen_extras.append(attach_dict_strategy)
 
     def _freeze_(self):
         return True


More information about the pypy-commit mailing list