Author: Matti Picus <[email protected]>
Branch: py3.6
Changeset: r98352:0ddf60ed10d2
Date: 2019-12-22 21:27 +0200
http://bitbucket.org/pypy/pypy/changeset/0ddf60ed10d2/
Log: test, fix for PyModule_AddFunctions, issue 3131
diff --git a/pypy/module/cpyext/modsupport.py b/pypy/module/cpyext/modsupport.py
--- a/pypy/module/cpyext/modsupport.py
+++ b/pypy/module/cpyext/modsupport.py
@@ -232,3 +232,14 @@
raise oefmt(space.w_SystemError, "PyModule_GetName(): not a module")
from pypy.module.cpyext.unicodeobject import PyUnicode_AsUTF8
return PyUnicode_AsUTF8(space, as_pyobj(space, w_mod.w_name))
+
+@cpython_api([PyObject, lltype.Ptr(PyMethodDef)], rffi.INT_real, error=-1)
+def PyModule_AddFunctions(space, w_mod, methods):
+ if not isinstance(w_mod, Module):
+ raise oefmt(space.w_SystemError, "PyModule_AddFuntions(): not a
module")
+ name = space.utf8_w(w_mod.w_name)
+ dict_w = {}
+ convert_method_defs(space, dict_w, methods, None, w_mod, name=name)
+ for key, w_value in dict_w.items():
+ space.setattr(w_mod, space.newtext(key), w_value)
+ return 0
diff --git a/pypy/module/cpyext/test/_widechar.c
b/pypy/module/cpyext/test/_widechar.c
--- a/pypy/module/cpyext/test/_widechar.c
+++ b/pypy/module/cpyext/test/_widechar.c
@@ -36,11 +36,7 @@
"_widechar",
NULL,
-1,
- TestMethods,
NULL,
- NULL,
- NULL,
- NULL
};
PyMODINIT_FUNC
@@ -50,5 +46,6 @@
m = PyModule_Create(&_testcapimodule);
if (m == NULL)
return NULL;
+ PyModule_AddFunctions(m, TestMethods);
return m;
}
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit