aboutsummaryrefslogtreecommitdiff
path: root/pypy
diff options
context:
space:
mode:
authorYannick Jadoul <yannick.jadoul@belgacom.net>2020-10-18 22:43:18 +0200
committerYannick Jadoul <yannick.jadoul@belgacom.net>2020-10-18 22:43:18 +0200
commit0692a827a355691eb9f5f8113c2a3c37de1f7936 (patch)
tree3e24956a4b2ecd6393a2ed47808ea0668b9b0813 /pypy
parentskip pattern in socket.inte_pton on windows, fails also on CPython (diff)
downloadpypy-0692a827a355691eb9f5f8113c2a3c37de1f7936.tar.gz
pypy-0692a827a355691eb9f5f8113c2a3c37de1f7936.tar.bz2
pypy-0692a827a355691eb9f5f8113c2a3c37de1f7936.zip
Change parameter type of PyModule_New to const char*, and use build_type_checkers to define PyModule_Check and PyModule_CheckExact
Diffstat (limited to 'pypy')
-rw-r--r--pypy/module/cpyext/api.py4
-rw-r--r--pypy/module/cpyext/modsupport.py13
-rw-r--r--pypy/module/cpyext/stubs.py7
3 files changed, 6 insertions, 18 deletions
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
index 6d540139de..25989b8475 100644
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -789,7 +789,7 @@ def build_type_checkers(type_name, cls=None):
return space.gettypeobject(cls.typedef)
check_name = "Py" + type_name + "_Check"
- @cts.decl("int %s(void * obj)" % check_name, error=CANNOT_FAIL)
+ @cts.decl("int %s(PyObject *obj)" % check_name, error=CANNOT_FAIL)
def check(space, w_obj):
"Implements the Py_Xxx_Check function"
w_obj_type = space.type(w_obj)
@@ -797,7 +797,7 @@ def build_type_checkers(type_name, cls=None):
return (space.is_w(w_obj_type, w_type) or
space.issubtype_w(w_obj_type, w_type))
- @cts.decl("int %sExact(void * obj)" % check_name, error=CANNOT_FAIL)
+ @cts.decl("int %sExact(PyObject *obj)" % check_name, error=CANNOT_FAIL)
def check_exact(space, w_obj):
"Implements the Py_Xxx_CheckExact function"
w_obj_type = space.type(w_obj)
diff --git a/pypy/module/cpyext/modsupport.py b/pypy/module/cpyext/modsupport.py
index ea27269b5b..b5d212b81b 100644
--- a/pypy/module/cpyext/modsupport.py
+++ b/pypy/module/cpyext/modsupport.py
@@ -1,7 +1,7 @@
from rpython.rtyper.lltypesystem import rffi, lltype
from pypy.module.cpyext.api import cpython_api, cpython_struct, \
METH_STATIC, METH_CLASS, METH_COEXIST, CANNOT_FAIL, CONST_STRING, \
- METH_NOARGS, METH_O, METH_VARARGS
+ METH_NOARGS, METH_O, METH_VARARGS, build_type_checkers
from pypy.module.cpyext.pyobject import PyObject, as_pyobj
from pypy.interpreter.module import Module
from pypy.module.cpyext.methodobject import (
@@ -11,7 +11,9 @@ from pypy.module.cpyext.pyerrors import PyErr_BadInternalCall
from pypy.module.cpyext.state import State
from pypy.interpreter.error import oefmt
-@cpython_api([rffi.CCHARP], PyObject)
+PyModule_Check, PyModule_CheckExact = build_type_checkers("Module", Module)
+
+@cpython_api([CONST_STRING], PyObject)
def PyModule_New(space, name):
"""
Return a new module object with the __name__ attribute set to name.
@@ -116,13 +118,6 @@ def convert_method_defs(space, dict_w, methods, w_type, w_self=None, name=None):
dict_w[methodname] = w_obj
-@cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
-def PyModule_Check(space, w_obj):
- w_type = space.gettypeobject(Module.typedef)
- w_obj_type = space.type(w_obj)
- return int(space.is_w(w_type, w_obj_type) or
- space.issubtype_w(w_obj_type, w_type))
-
@cpython_api([PyObject], PyObject, result_borrowed=True)
def PyModule_GetDict(space, w_mod):
if PyModule_Check(space, w_mod):
diff --git a/pypy/module/cpyext/stubs.py b/pypy/module/cpyext/stubs.py
index 3dba4ffa8a..23e818ee94 100644
--- a/pypy/module/cpyext/stubs.py
+++ b/pypy/module/cpyext/stubs.py
@@ -1203,13 +1203,6 @@ def PyMethod_ClearFreeList(space):
"""
raise NotImplementedError
-@cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
-def PyModule_CheckExact(space, p):
- """Return true if p is a module object, but not a subtype of
- PyModule_Type.
- """
- raise NotImplementedError
-
@cpython_api([PyObject], rffi.CCHARP)
def PyModule_GetFilename(space, module):
"""Return the name of the file from which module was loaded using module's