diff options
author | Jelmer Vernooij <jelmer@jelmer.uk> | 2016-07-08 22:13:52 +0000 |
---|---|---|
committer | Jelmer Vernooij <jelmer@jelmer.uk> | 2016-07-08 22:13:52 +0000 |
commit | 519ebeac5c3e2a4d1266d5b4ed65f8e22bf576d2 (patch) | |
tree | d79e44281b1e0461e45f5706a3f2094ef7ebd6ae /subvertpy/repos.c | |
parent | fb0a735f270a5fc3c948679c8b946d180ef8dabc (diff) |
Fix init function use in C modules for Python3.
Diffstat (limited to 'subvertpy/repos.c')
-rw-r--r-- | subvertpy/repos.c | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/subvertpy/repos.c b/subvertpy/repos.c index 6f1e3c2b..cf2c065b 100644 --- a/subvertpy/repos.c +++ b/subvertpy/repos.c @@ -928,33 +928,48 @@ PyTypeObject FileSystemRoot_Type = { }; -void initrepos(void) +static PyObject *moduleinit(void) { static apr_pool_t *pool; PyObject *mod; if (PyType_Ready(&Repository_Type) < 0) - return; + return NULL; if (PyType_Ready(&FileSystem_Type) < 0) - return; + return NULL; if (PyType_Ready(&FileSystemRoot_Type) < 0) - return; + return NULL; if (PyType_Ready(&Stream_Type) < 0) - return; + return NULL; apr_initialize(); pool = Pool(NULL); if (pool == NULL) - return; + return NULL; svn_fs_initialize(pool); +#if PY_MAJOR_VERSION >= 3 + static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "repos", /* m_name */ + "Local repository management.", /* m_doc */ + -1, /* m_size */ + repos_module_methods, /* m_methods */ + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear*/ + NULL, /* m_free */ + }; + mod = PyModule_Create(&moduledef); +#else mod = Py_InitModule3("repos", repos_module_methods, "Local repository management"); +#endif if (mod == NULL) - return; + return NULL; PyModule_AddObject(mod, "LOAD_UUID_DEFAULT", PyLong_FromLong(svn_repos_load_uuid_default)); PyModule_AddObject(mod, "LOAD_UUID_IGNORE", PyLong_FromLong(svn_repos_load_uuid_ignore)); @@ -977,4 +992,20 @@ void initrepos(void) PyModule_AddObject(mod, "Stream", (PyObject *)&Stream_Type); Py_INCREF(&Stream_Type); + + return mod; +} + +#if PY_MAJOR_VERSION >= 3 +PyMODINIT_FUNC +PyInit_repos(void) +{ + return moduleinit(); } +#else +PyMODINIT_FUNC +initrepos(void) +{ + moduleinit(); +} +#endif |