Skip to content

Commit 9111f17

Browse files
committed
Add version
1 parent 45b2330 commit 9111f17

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

selectlib.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* selectlib.c */
2-
31
#include <Python.h>
42
#include <listobject.h>
53
#include <stdlib.h>
@@ -9,6 +7,10 @@
97
#define PY_SSIZE_T_CLEAN
108
#endif
119

10+
#ifndef SELECTLIB_VERSION
11+
#define SELECTLIB_VERSION "1.0.0"
12+
#endif
13+
1214
/*
1315
Helper function that compares two PyObject*s using the < operator.
1416
Returns 1 if a < b, 0 if not, or -1 if an error occurred.
@@ -214,5 +216,13 @@ static struct PyModuleDef selectlibmodule = {
214216
PyMODINIT_FUNC
215217
PyInit_selectlib(void)
216218
{
217-
return PyModule_Create(&selectlibmodule);
219+
PyObject *m = PyModule_Create(&selectlibmodule);
220+
if (m == NULL)
221+
return NULL;
222+
/* Add the module's version constant */
223+
if (PyModule_AddStringConstant(m, "__version__", SELECTLIB_VERSION) < 0) {
224+
Py_DECREF(m);
225+
return NULL;
226+
}
227+
return m;
218228
}

0 commit comments

Comments
 (0)