Author: Antonio Cuni <[email protected]>
Branch: hpy
Changeset: r98212:121bac5f857c
Date: 2019-12-02 10:46 +0100
http://bitbucket.org/pypy/pypy/changeset/121bac5f857c/

Log:    progress towards making test_ztranslation working again: these
        changes are needed to that functions inside
        hpy_universal.interp_list are annotated correctly, because they do
        'assert isinstance(w_obj, W_ListObject)', so they bring in real code
        from the std objspace

diff --git a/pypy/module/hpy_universal/test/test_ztranslation.py 
b/pypy/module/hpy_universal/test/test_ztranslation.py
--- a/pypy/module/hpy_universal/test/test_ztranslation.py
+++ b/pypy/module/hpy_universal/test/test_ztranslation.py
@@ -10,8 +10,10 @@
         state = space.fromcache(State)
         state.setup()
 
-    config_opts = {'translation.gc': 'boehm'}
+    rpython_opts = {'translation.gc': 'boehm'}
+    pypy_opts = {'objspace.std.withliststrategies': False}
     checkmodule('hpy_universal',
                 extra_func=extra_func,
                 c_compile=True,
-                config_opts=config_opts)
+                rpython_opts=rpython_opts,
+                pypy_opts=pypy_opts)
diff --git a/pypy/objspace/fake/checkmodule.py 
b/pypy/objspace/fake/checkmodule.py
--- a/pypy/objspace/fake/checkmodule.py
+++ b/pypy/objspace/fake/checkmodule.py
@@ -3,7 +3,8 @@
 
 
 def checkmodule(modname, translate_startup=True, ignore=(),
-                c_compile=False, extra_func=None, config_opts=None):
+                c_compile=False, extra_func=None, rpython_opts=None,
+                pypy_opts=None):
     """
     Check that the module 'modname' translates.
 
@@ -21,6 +22,8 @@
                    will be passed to TranslationContext
     """
     config = get_pypy_config(translating=True)
+    if pypy_opts:
+        config.set(**pypy_opts)
     space = FakeObjSpace(config)
     seeobj_w = []
     modules = []
@@ -51,7 +54,7 @@
         func = None
 
     opts = {'translation.list_comprehension_operations': True}
-    if config_opts:
-        opts.update(config_opts)
+    if rpython_opts:
+        opts.update(rpython_opts)
     space.translates(func, seeobj_w=seeobj_w,
                      c_compile=c_compile, extra_func=extra_func, **opts)
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
@@ -78,7 +78,6 @@
     def _len(self):
         return self._length
 
-
 class W_MyType(W_MyObject):
     name = "foobar"
     flag_map_or_seq = '?'
@@ -154,10 +153,18 @@
         def build_slice():
             self.newslice(self.w_None, self.w_None, self.w_None)
         def attach_list_strategy():
-            from pypy.objspace.std.listobject import W_ListObject, 
EmptyListStrategy
+            # this is needed for modules which interacts directly with
+            # std.listobject.W_ListObject, e.g. after an isinstance check. For
+            # example, hpy_universal. We need to attach a couple of attributes
+            # so that the annotator annotates them with the correct types
+            from pypy.objspace.std.listobject import W_ListObject, 
ObjectListStrategy
+            space = self
             w_obj = w_some_obj()
             if isinstance(w_obj, W_ListObject):
-                w_obj.strategy = EmptyListStrategy(self)
+                w_obj.space = space
+                w_obj.strategy = ObjectListStrategy(space)
+                list_w = [w_some_obj(), w_some_obj()]
+                w_obj.lstorage = w_obj.strategy.erase(list_w)
         self._seen_extras.append(build_slice)
         self._seen_extras.append(attach_list_strategy)
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to