[pypy-commit] pypy hpy: pass the module as 'self' when calling HPyFunctionDefs. test_self_is_module passes

antocuni pypy.commits at gmail.com
Sat Nov 16 19:16:17 EST 2019


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: hpy
Changeset: r98087:1cbaaff6fda2
Date: 2019-11-17 00:43 +0100
http://bitbucket.org/pypy/pypy/changeset/1cbaaff6fda2/

Log:	pass the module as 'self' when calling HPyFunctionDefs.
	test_self_is_module passes

diff --git a/pypy/module/hpy_universal/interp_extfunc.py b/pypy/module/hpy_universal/interp_extfunc.py
--- a/pypy/module/hpy_universal/interp_extfunc.py
+++ b/pypy/module/hpy_universal/interp_extfunc.py
@@ -11,8 +11,9 @@
 class W_ExtensionFunction(W_Root):
     _immutable_fields_ = ["flags", "name"]
 
-    def __init__(self, ml):
+    def __init__(self, ml, w_self):
         self.ml = ml
+        self.w_self = w_self
         self.name = rffi.charp2str(self.ml.c_ml_name)
         self.flags = rffi.cast(lltype.Signed, self.ml.c_ml_flags)
         # fetch the real HPy function pointer, by calling ml_meth, which
@@ -30,8 +31,10 @@
 
     def call_noargs(self, space):
         state = space.fromcache(State)
+        h_self = handles.new(space, self.w_self)
         h_result = generic_cpy_call_dont_convert_result(space, self.cfuncptr,
-            state.ctx, 0, 0)
+            state.ctx, h_self, 0)
+        handles.consume(space, h_self)
         # XXX check for exceptions
         return handles.consume(space, h_result)
 
diff --git a/pypy/module/hpy_universal/interp_hpy.py b/pypy/module/hpy_universal/interp_hpy.py
--- a/pypy/module/hpy_universal/interp_hpy.py
+++ b/pypy/module/hpy_universal/interp_hpy.py
@@ -40,7 +40,7 @@
         p = hpydef.c_m_methods
         i = 0
         while p[i].c_ml_name:
-            w_extfunc = interp_extfunc.W_ExtensionFunction(p[i])
+            w_extfunc = interp_extfunc.W_ExtensionFunction(p[i], w_mod)
             space.setattr(w_mod, space.newtext(w_extfunc.name), w_extfunc)
             i += 1
     #


More information about the pypy-commit mailing list