Author: Antonio Cuni <[email protected]>
Branch: hpy
Changeset: r98167:e2ab328b16a8
Date: 2019-11-28 10:52 +0100
http://bitbucket.org/pypy/pypy/changeset/e2ab328b16a8/
Log: use the updated values for HPy_METH_*
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
@@ -78,27 +78,27 @@
flags = self.flags
length = len(__args__.arguments_w)
- if flags & llapi.METH_KEYWORDS:
+ if flags == llapi.HPy_METH_KEYWORDS:
return self.call_keywords(space, __args__)
if __args__.keywords:
raise oefmt(space.w_TypeError,
"%s() takes no keyword arguments", self.name)
- if flags & llapi.METH_NOARGS:
+ if flags == llapi.HPy_METH_NOARGS:
if length == 0:
return self.call_noargs(space)
raise oefmt(space.w_TypeError,
"%s() takes no arguments", self.name)
- if flags & llapi.METH_O:
+ if flags == llapi.HPy_METH_O:
if length != 1:
raise oefmt(space.w_TypeError,
"%s() takes exactly one argument (%d given)",
self.name, length)
return self.call_o(space, __args__.arguments_w[0])
- if flags & llapi.METH_VARARGS:
+ if flags == llapi.HPy_METH_VARARGS:
return self.call_varargs(space, __args__.arguments_w)
else: # shouldn't happen!
raise oefmt(space.w_RuntimeError, "unknown calling convention")
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
@@ -7,7 +7,7 @@
from pypy.interpreter.gateway import unwrap_spec
from pypy.interpreter.error import raise_import_error
from pypy.interpreter.module import Module
-from pypy.interpreter.error import OperationError
+from pypy.interpreter.error import OperationError, oefmt
from pypy.module.hpy_universal import llapi, handles, interp_extfunc
from pypy.module.hpy_universal.state import State
@@ -40,6 +40,10 @@
p = hpydef.c_m_methods
i = 0
while p[i].c_ml_name:
+ if not p[i].c_ml_flags & llapi._HPy_METH:
+ # we need to add support for legacy methods through cpyext
+ raise oefmt(space.w_NotImplementedError, "non-hpy method: %s",
+ rffi.charp2str(p[i].c_ml_name))
w_extfunc = interp_extfunc.W_ExtensionFunction(p[i], w_mod)
space.setattr(w_mod, space.newtext(w_extfunc.name), w_extfunc)
i += 1
diff --git a/pypy/module/hpy_universal/llapi.py
b/pypy/module/hpy_universal/llapi.py
--- a/pypy/module/hpy_universal/llapi.py
+++ b/pypy/module/hpy_universal/llapi.py
@@ -136,13 +136,11 @@
# HPyModule_Create
HPyModuleDef._flds['c_m_methods'] = rffi.CArrayPtr(HPyMethodDef)
-METH_VARARGS = 0x0001
-METH_KEYWORDS = 0x0002
-METH_NOARGS = 0x0004
-METH_O = 0x0008
-
-
-
+_HPy_METH = 0x100000
+HPy_METH_VARARGS = 0x0001 | _HPy_METH
+HPy_METH_KEYWORDS = 0x0002 | _HPy_METH
+HPy_METH_NOARGS = 0x0004 | _HPy_METH
+HPy_METH_O = 0x0008 | _HPy_METH
# ----------------------------------------------------------------
diff --git a/pypy/module/hpy_universal/test/support.py
b/pypy/module/hpy_universal/test/support.py
--- a/pypy/module/hpy_universal/test/support.py
+++ b/pypy/module/hpy_universal/test/support.py
@@ -5,6 +5,7 @@
from pypy.module.hpy_universal.llapi import INCLUDE_DIR
from pypy.module.hpy_universal._vendored.test import support as _support
+COMPILER_VERBOSE = False
class HPyAppTest(object):
@@ -24,7 +25,8 @@
tmpdir = py.path.local.make_numbered_dir(rootdir=udir,
prefix=meth.__name__ + '-',
keep=0) # keep everything
- compiler = _support.ExtensionCompiler(tmpdir, 'universal', INCLUDE_DIR)
+ compiler = _support.ExtensionCompiler(tmpdir, 'universal', INCLUDE_DIR,
+
compiler_verbose=COMPILER_VERBOSE)
@unwrap_spec(source_template='text', name='text',
w_extra_templates=W_Root)
def descr_make_module(space, source_template, name='mytest',
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit