summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2016-08-21 07:43:58 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2016-08-21 07:43:58 (GMT)
commitcbcd221de4f13a855ba37d48a238895e4ddc92f4 (patch)
tree07b1b549e44c6feeeec8ebd4cd6d03642a7b1932 /Modules
parentf9ed528fafafda147f20f345195ced23b141ace9 (diff)
parent8682f578c1c8fd0486c886b001729907a5409a9f (diff)
downloadcpython-cbcd221de4f13a855ba37d48a238895e4ddc92f4.zip
cpython-cbcd221de4f13a855ba37d48a238895e4ddc92f4.tar.gz
cpython-cbcd221de4f13a855ba37d48a238895e4ddc92f4.tar.bz2
Merge #27782 fix from 3.5
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_testmultiphase.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/Modules/_testmultiphase.c b/Modules/_testmultiphase.c
index 03eda27..4daa34e 100644
--- a/Modules/_testmultiphase.c
+++ b/Modules/_testmultiphase.c
@@ -248,6 +248,7 @@ PyInit__testmultiphase(PyObject *spec)
/**** Importing a non-module object ****/
static PyModuleDef def_nonmodule;
+static PyModuleDef def_nonmodule_with_methods;
/* Create a SimpleNamespace(three=3) */
static PyObject*
@@ -255,7 +256,7 @@ createfunc_nonmodule(PyObject *spec, PyModuleDef *def)
{
PyObject *dct, *ns, *three;
- if (def != &def_nonmodule) {
+ if (def != &def_nonmodule && def != &def_nonmodule_with_methods) {
PyErr_SetString(PyExc_SystemError, "def does not match");
return NULL;
}
@@ -291,6 +292,36 @@ PyInit__testmultiphase_nonmodule(PyObject *spec)
return PyModuleDef_Init(&def_nonmodule);
}
+PyDoc_STRVAR(nonmodule_bar_doc,
+"bar(i,j)\n\
+\n\
+Return the difference of i - j.");
+
+static PyObject *
+nonmodule_bar(PyObject *self, PyObject *args)
+{
+ long i, j;
+ long res;
+ if (!PyArg_ParseTuple(args, "ll:bar", &i, &j))
+ return NULL;
+ res = i - j;
+ return PyLong_FromLong(res);
+}
+
+static PyMethodDef nonmodule_methods[] = {
+ {"bar", nonmodule_bar, METH_VARARGS, nonmodule_bar_doc},
+ {NULL, NULL} /* sentinel */
+};
+
+static PyModuleDef def_nonmodule_with_methods = TEST_MODULE_DEF(
+ "_testmultiphase_nonmodule_with_methods", slots_create_nonmodule, nonmodule_methods);
+
+PyMODINIT_FUNC
+PyInit__testmultiphase_nonmodule_with_methods(PyObject *spec)
+{
+ return PyModuleDef_Init(&def_nonmodule_with_methods);
+}
+
/**** Non-ASCII-named modules ****/
static PyModuleDef def_nonascii_latin = { \