summaryrefslogtreecommitdiff
path: root/src/block_template.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/block_template.c')
-rw-r--r--src/block_template.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/block_template.c b/src/block_template.c
index d932ce9..436a4cc 100644
--- a/src/block_template.c
+++ b/src/block_template.c
@@ -715,6 +715,7 @@ _MODULE_NAME (void)
{
PyObject *m = NULL;
PyObject *abiver = NULL;
+ PyObject *__all__ = NULL;
if (PyType_Ready(&ALGtype) < 0)
goto errout;
@@ -728,6 +729,11 @@ _MODULE_NAME (void)
if (m == NULL)
goto errout;
+ /* Add the type object to the module (using the name of the module itself),
+ * so that its methods docstrings are discoverable by introspection tools. */
+ PyObject_SetAttrString(m, _MODULE_STRING, (PyObject *)&ALGtype);
+
+ /* Add some symbolic constants to the module */
PyModule_AddIntConstant(m, "MODE_ECB", MODE_ECB);
PyModule_AddIntConstant(m, "MODE_CBC", MODE_CBC);
PyModule_AddIntConstant(m, "MODE_CFB", MODE_CFB);
@@ -756,6 +762,22 @@ _MODULE_NAME (void)
goto errout;
}
+ /* Create __all__ (to help generate documentation) */
+ __all__ = PyList_New(10);
+ if (__all__ == NULL)
+ goto errout;
+ PyList_SetItem(__all__, 0, PyString_FromString(_MODULE_STRING)); /* This is the ALGType object */
+ PyList_SetItem(__all__, 1, PyString_FromString("new"));
+ PyList_SetItem(__all__, 2, PyString_FromString("MODE_ECB"));
+ PyList_SetItem(__all__, 3, PyString_FromString("MODE_CBC"));
+ PyList_SetItem(__all__, 4, PyString_FromString("MODE_CFB"));
+ PyList_SetItem(__all__, 5, PyString_FromString("MODE_PGP"));
+ PyList_SetItem(__all__, 6, PyString_FromString("MODE_OFB"));
+ PyList_SetItem(__all__, 7, PyString_FromString("MODE_CTR"));
+ PyList_SetItem(__all__, 8, PyString_FromString("block_size"));
+ PyList_SetItem(__all__, 9, PyString_FromString("key_size"));
+ PyObject_SetAttrString(m, "__all__", __all__);
+
out:
/* Final error check */
if (m == NULL && !PyErr_Occurred()) {
@@ -765,6 +787,7 @@ out:
/* Free local objects here */
Py_CLEAR(abiver);
+ Py_CLEAR(__all__);
/* Return */
#ifdef IS_PY3K