Author: Ronan Lamy <[email protected]>
Branch: py3k
Changeset: r85977:7b64c8a8597e
Date: 2016-08-02 02:53 +0100
http://bitbucket.org/pypy/pypy/changeset/7b64c8a8597e/
Log: Port test_import_module.c to 3
diff --git a/pypy/module/cpyext/test/test_import_module.c
b/pypy/module/cpyext/test/test_import_module.c
--- a/pypy/module/cpyext/test/test_import_module.c
+++ b/pypy/module/cpyext/test/test_import_module.c
@@ -1,17 +1,20 @@
#include "Python.h"
/* Initialize this module. */
+static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ "test_import_module",
+ NULL,
+ -1,
+ NULL, NULL, NULL, NULL, NULL
+};
+
PyMODINIT_FUNC
-inittest_import_module(void)
+PyInit_test_import_module(void)
{
- PyObject *m, *d;
-
- m = Py_InitModule("test_import_module", NULL);
- if (m == NULL)
- return;
- d = PyModule_GetDict(m);
- if (d) {
- PyDict_SetItemString(d, "TEST", (PyObject *) Py_None);
- }
- /* No need to check the error here, the caller will do that */
+ PyObject* m = PyModule_Create(&moduledef);
+ if (m == NULL)
+ return NULL;
+ PyModule_AddObject(m, "TEST", (PyObject *) Py_None);
+ return m;
}
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit