From 6a1374d2a09d5e969c3379a95c2a234c4faff7b5 Mon Sep 17 00:00:00 2001 From: "oleg.hoefling" Date: Fri, 28 May 2021 17:14:46 +0200 Subject: [PATCH 1/7] replace PyString_FromString usages with PyUnicode_FromString Signed-off-by: oleg.hoefling --- src/constants.c | 22 +++++++++++----------- src/keys.c | 2 +- src/platform.h | 2 -- src/template.c | 2 +- src/utils.c | 2 +- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/constants.c b/src/constants.c index 93c6e434..66aa88c7 100644 --- a/src/constants.c +++ b/src/constants.c @@ -27,7 +27,7 @@ static PyObject* PyXmlSec_Transform__str__(PyObject* self) { else snprintf(buf, sizeof(buf), "%s, None", transform->id->name); - return PyString_FromString(buf); + return PyUnicode_FromString(buf); } // __repr__ method @@ -38,18 +38,18 @@ static PyObject* PyXmlSec_Transform__repr__(PyObject* self) { snprintf(buf, sizeof(buf), "__Transform('%s', '%s', %d)", transform->id->name, transform->id->href, transform->id->usage); else snprintf(buf, sizeof(buf), "__Transform('%s', None, %d)", transform->id->name, transform->id->usage); - return PyString_FromString(buf); + return PyUnicode_FromString(buf); } static const char PyXmlSec_TransformNameGet__doc__[] = "The transform's name."; static PyObject* PyXmlSec_TransformNameGet(PyXmlSec_Transform* self, void* closure) { - return PyString_FromString((const char*)self->id->name); + return PyUnicode_FromString((const char*)self->id->name); } static const char PyXmlSec_TransformHrefGet__doc__[] = "The transform's identification string (href)."; static PyObject* PyXmlSec_TransformHrefGet(PyXmlSec_Transform* self, void* closure) { if (self->id->href != NULL) - return PyString_FromString((const char*)self->id->href); + return PyUnicode_FromString((const char*)self->id->href); Py_RETURN_NONE; } @@ -149,7 +149,7 @@ static PyObject* PyXmlSec_KeyData__str__(PyObject* self) { snprintf(buf, sizeof(buf), "%s, %s", keydata->id->name, keydata->id->href); else snprintf(buf, sizeof(buf), "%s, None", keydata->id->name); - return PyString_FromString(buf); + return PyUnicode_FromString(buf); } // __repr__ method @@ -160,18 +160,18 @@ static PyObject* PyXmlSec_KeyData__repr__(PyObject* self) { snprintf(buf, sizeof(buf), "__KeyData('%s', '%s')", keydata->id->name, keydata->id->href); else snprintf(buf, sizeof(buf), "__KeyData('%s', None)", keydata->id->name); - return PyString_FromString(buf); + return PyUnicode_FromString(buf); } static const char PyXmlSec_KeyDataNameGet__doc__[] = "The key data's name."; static PyObject* PyXmlSec_KeyDataNameGet(PyXmlSec_KeyData* self, void* closure) { - return PyString_FromString((const char*)self->id->name); + return PyUnicode_FromString((const char*)self->id->name); } static const char PyXmlSec_KeyDataHrefGet__doc__[] = "The key data's identification string (href)."; static PyObject* PyXmlSec_KeyDataHrefGet(PyXmlSec_KeyData* self, void* closure) { if (self->id->href != NULL) - return PyString_FromString((const char*)self->id->href); + return PyUnicode_FromString((const char*)self->id->href); Py_RETURN_NONE; } @@ -308,7 +308,7 @@ int PyXmlSec_ConstantsModule_Init(PyObject* package) { #define PYXMLSEC_ADD_NS_CONSTANT(name, lname) \ - tmp = PyString_FromString((const char*)(JOIN(xmlSec, name))); \ + tmp = PyUnicode_FromString((const char*)(JOIN(xmlSec, name))); \ PYXMLSEC_ADD_CONSTANT(nsCls, name, lname); // namespaces @@ -334,7 +334,7 @@ int PyXmlSec_ConstantsModule_Init(PyObject* package) { #define PYXMLSEC_ADD_ENC_CONSTANT(name, lname) \ - tmp = PyString_FromString((const char*)(JOIN(xmlSec, name))); \ + tmp = PyUnicode_FromString((const char*)(JOIN(xmlSec, name))); \ PYXMLSEC_ADD_CONSTANT(encryptionTypeCls, name, lname); // encryption type @@ -349,7 +349,7 @@ int PyXmlSec_ConstantsModule_Init(PyObject* package) { #define PYXMLSEC_ADD_NODE_CONSTANT(name, lname) \ - tmp = PyString_FromString((const char*)(JOIN(xmlSec, name))); \ + tmp = PyUnicode_FromString((const char*)(JOIN(xmlSec, name))); \ PYXMLSEC_ADD_CONSTANT(nodeCls, name, lname); // node diff --git a/src/keys.c b/src/keys.c index 357cc9c7..83419623 100644 --- a/src/keys.c +++ b/src/keys.c @@ -436,7 +436,7 @@ static PyObject* PyXmlSec_KeyNameGet(PyObject* self, void* closure) { } cname = (const char*)xmlSecKeyGetName(key->handle); if (cname != NULL) { - return PyString_FromString(cname); + return PyUnicode_FromString(cname); } Py_RETURN_NONE; } diff --git a/src/platform.h b/src/platform.h index 01312a11..a45b8b82 100644 --- a/src/platform.h +++ b/src/platform.h @@ -40,8 +40,6 @@ typedef int Py_ssize_t; #define PyString_Check PyUnicode_Check #define PyString_FromStringAndSize PyUnicode_FromStringAndSize -#define PyString_FromString PyUnicode_FromString - #define PyString_AsString PyUnicode_AsUTF8 #define PyString_AsUtf8AndSize PyUnicode_AsUTF8AndSize diff --git a/src/template.c b/src/template.c index 7d043606..9d19aaf3 100644 --- a/src/template.c +++ b/src/template.c @@ -766,7 +766,7 @@ static PyObject* PyXmlSec_TemplateTransformAddC14NInclNamespaces(PyObject* self, goto ON_FAIL; } if (PyList_Check(prefixes) || PyTuple_Check(prefixes)) { - sep = PyString_FromString(" "); + sep = PyUnicode_FromString(" "); prefixes = PyObject_CallMethod(sep, "join", "O", prefixes); Py_DECREF(sep); } else if (PyString_Check(prefixes)) { diff --git a/src/utils.c b/src/utils.c index ea6867f3..5f716128 100644 --- a/src/utils.c +++ b/src/utils.c @@ -32,7 +32,7 @@ PyObject* PyXmlSec_GetFilePathOrContent(PyObject* file, int* is_content) { } int PyXmlSec_SetStringAttr(PyObject* obj, const char* name, const char* value) { - PyObject* tmp = PyString_FromString(value); + PyObject* tmp = PyUnicode_FromString(value); int r; if (tmp == NULL) { From 908edee62f02a30ea9a780caa980d01a8f837642 Mon Sep 17 00:00:00 2001 From: "oleg.hoefling" Date: Fri, 28 May 2021 17:16:21 +0200 Subject: [PATCH 2/7] replace PyString_Check usages with PyUnicode_Check Signed-off-by: oleg.hoefling --- src/platform.h | 2 -- src/template.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/platform.h b/src/platform.h index a45b8b82..dea74417 100644 --- a/src/platform.h +++ b/src/platform.h @@ -37,7 +37,6 @@ typedef int Py_ssize_t; #if PY_MAJOR_VERSION >= 3 #define PY3K 1 -#define PyString_Check PyUnicode_Check #define PyString_FromStringAndSize PyUnicode_FromStringAndSize #define PyString_AsString PyUnicode_AsUTF8 @@ -48,7 +47,6 @@ typedef int Py_ssize_t; #define PyString_FSConverter PyUnicode_FSConverter #else // PY3K -#define PyBytes_Check PyString_Check #define PyBytes_FromStringAndSize PyString_FromStringAndSize #define PyBytes_AsString PyString_AsString diff --git a/src/template.c b/src/template.c index 9d19aaf3..2fb87369 100644 --- a/src/template.c +++ b/src/template.c @@ -769,7 +769,7 @@ static PyObject* PyXmlSec_TemplateTransformAddC14NInclNamespaces(PyObject* self, sep = PyUnicode_FromString(" "); prefixes = PyObject_CallMethod(sep, "join", "O", prefixes); Py_DECREF(sep); - } else if (PyString_Check(prefixes)) { + } else if (PyUnicode_Check(prefixes)) { Py_INCREF(prefixes); } else { PyErr_SetString(PyExc_TypeError, "expected instance of str or list of str"); From 8977ff3232b54d56b25404e7f5ebd83cf6caf6ed Mon Sep 17 00:00:00 2001 From: "oleg.hoefling" Date: Fri, 28 May 2021 17:19:00 +0200 Subject: [PATCH 3/7] drop unused PyString_FromStringAndSize and PyString_AsUtf8AndSize Signed-off-by: oleg.hoefling --- src/platform.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/platform.h b/src/platform.h index dea74417..0062a930 100644 --- a/src/platform.h +++ b/src/platform.h @@ -37,26 +37,17 @@ typedef int Py_ssize_t; #if PY_MAJOR_VERSION >= 3 #define PY3K 1 -#define PyString_FromStringAndSize PyUnicode_FromStringAndSize #define PyString_AsString PyUnicode_AsUTF8 -#define PyString_AsUtf8AndSize PyUnicode_AsUTF8AndSize #define PyCreateDummyObject PyModule_New #define PyString_FSConverter PyUnicode_FSConverter #else // PY3K -#define PyBytes_FromStringAndSize PyString_FromStringAndSize - #define PyBytes_AsString PyString_AsString #define PyBytes_AsStringAndSize PyString_AsStringAndSize -static inline char* PyString_AsUtf8AndSize(PyObject *obj, Py_ssize_t* length) { - char* buffer = NULL; - return (PyString_AsStringAndSize(obj, &buffer, length) < 0) ? (char*)(0) : buffer; -} - static inline PyObject* PyCreateDummyObject(const char* name) { PyObject* tmp = Py_InitModule(name, NULL); Py_INCREF(tmp); From c1e269abdc36cf391ebdea45042fbf654e5fe92e Mon Sep 17 00:00:00 2001 From: "oleg.hoefling" Date: Fri, 28 May 2021 17:21:03 +0200 Subject: [PATCH 4/7] replace PyString_AsString usages with PyUnicode_AsUTF8 Signed-off-by: oleg.hoefling --- src/keys.c | 2 +- src/platform.h | 3 --- src/template.c | 2 +- src/tree.c | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/keys.c b/src/keys.c index 83419623..9e65be8f 100644 --- a/src/keys.c +++ b/src/keys.c @@ -460,7 +460,7 @@ static int PyXmlSec_KeyNameSet(PyObject* self, PyObject* value, void* closure) { return 0; } - name = PyString_AsString(value); + name = PyUnicode_AsUTF8(value); if (name == NULL) return -1; if (xmlSecKeySetName(key->handle, XSTR(name)) < 0) { diff --git a/src/platform.h b/src/platform.h index 0062a930..fe1c6f9b 100644 --- a/src/platform.h +++ b/src/platform.h @@ -38,14 +38,11 @@ typedef int Py_ssize_t; #if PY_MAJOR_VERSION >= 3 #define PY3K 1 -#define PyString_AsString PyUnicode_AsUTF8 - #define PyCreateDummyObject PyModule_New #define PyString_FSConverter PyUnicode_FSConverter #else // PY3K -#define PyBytes_AsString PyString_AsString #define PyBytes_AsStringAndSize PyString_AsStringAndSize static inline PyObject* PyCreateDummyObject(const char* name) { diff --git a/src/template.c b/src/template.c index 2fb87369..0d35832b 100644 --- a/src/template.c +++ b/src/template.c @@ -781,7 +781,7 @@ static PyObject* PyXmlSec_TemplateTransformAddC14NInclNamespaces(PyObject* self, } - c_prefixes = PyString_AsString(prefixes); + c_prefixes = PyUnicode_AsUTF8(prefixes); Py_BEGIN_ALLOW_THREADS; res = xmlSecTmplTransformAddC14NInclNamespaces(node->_c_node, XSTR(c_prefixes)); Py_END_ALLOW_THREADS; diff --git a/src/tree.c b/src/tree.c index 76037d3b..df8821c3 100644 --- a/src/tree.c +++ b/src/tree.c @@ -182,7 +182,7 @@ static PyObject* PyXmlSec_TreeAddIds(PyObject* self, PyObject *args, PyObject *k tmp = PyObject_GetItem(ids, key); Py_DECREF(key); if (tmp == NULL) goto ON_FAIL; - list[i] = XSTR(PyString_AsString(tmp)); + list[i] = XSTR(PyUnicode_AsUTF8(tmp)); Py_DECREF(tmp); if (list[i] == NULL) goto ON_FAIL; } From d29be044a03aec424ecc0602a0ab8d79c7311d94 Mon Sep 17 00:00:00 2001 From: "oleg.hoefling" Date: Fri, 28 May 2021 17:22:35 +0200 Subject: [PATCH 5/7] replace PyCreateDummyObject usages with PyModule_New Signed-off-by: oleg.hoefling --- src/constants.c | 2 +- src/platform.h | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/constants.c b/src/constants.c index 66aa88c7..938d5834 100644 --- a/src/constants.c +++ b/src/constants.c @@ -292,7 +292,7 @@ int PyXmlSec_ConstantsModule_Init(PyObject* package) { #undef PYXMLSEC_ADD_INT_CONSTANT #define PYXMLSEC_DECLARE_NAMESPACE(var, name) \ - if (!(var = PyCreateDummyObject(name))) goto ON_FAIL; \ + if (!(var = PyModule_New(name))) goto ON_FAIL; \ if (PyModule_AddObject(package, name, var) < 0) goto ON_FAIL; \ Py_INCREF(var); // add object steels reference diff --git a/src/platform.h b/src/platform.h index fe1c6f9b..25c24d19 100644 --- a/src/platform.h +++ b/src/platform.h @@ -38,19 +38,11 @@ typedef int Py_ssize_t; #if PY_MAJOR_VERSION >= 3 #define PY3K 1 -#define PyCreateDummyObject PyModule_New - #define PyString_FSConverter PyUnicode_FSConverter #else // PY3K #define PyBytes_AsStringAndSize PyString_AsStringAndSize -static inline PyObject* PyCreateDummyObject(const char* name) { - PyObject* tmp = Py_InitModule(name, NULL); - Py_INCREF(tmp); - return tmp; -} - static inline int PyString_FSConverter(PyObject* o, PyObject** p) { if (o == NULL) { return 0; From cfe61ea2c4040a5ce11d003ef894412eddc7be89 Mon Sep 17 00:00:00 2001 From: "oleg.hoefling" Date: Fri, 28 May 2021 17:26:07 +0200 Subject: [PATCH 6/7] replace PyString_FSConverter usages with PyUnicode_FSConverter Signed-off-by: oleg.hoefling --- src/keys.c | 4 ++-- src/platform.h | 12 ------------ src/utils.c | 2 +- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/keys.c b/src/keys.c index 9e65be8f..8e065ea0 100644 --- a/src/keys.c +++ b/src/keys.c @@ -249,7 +249,7 @@ static PyObject* PyXmlSec_KeyFromBinaryFile(PyObject* self, PyObject* args, PyOb PYXMLSEC_DEBUG("load symmetric key - start"); if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O&:from_binary_file", kwlist, - PyXmlSec_KeyDataType, &keydata, PyString_FSConverter, &filepath)) + PyXmlSec_KeyDataType, &keydata, PyUnicode_FSConverter, &filepath)) { goto ON_FAIL; } @@ -698,7 +698,7 @@ static PyObject* PyXmlSec_KeysManagerLoadCert(PyObject* self, PyObject* args, Py PYXMLSEC_DEBUGF("%p: load cert - start", self); if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&II:load_cert", kwlist, - PyString_FSConverter, &filepath, &format, &type)) { + PyUnicode_FSConverter, &filepath, &format, &type)) { goto ON_FAIL; } diff --git a/src/platform.h b/src/platform.h index 25c24d19..35705f2d 100644 --- a/src/platform.h +++ b/src/platform.h @@ -37,22 +37,10 @@ typedef int Py_ssize_t; #if PY_MAJOR_VERSION >= 3 #define PY3K 1 - -#define PyString_FSConverter PyUnicode_FSConverter #else // PY3K #define PyBytes_AsStringAndSize PyString_AsStringAndSize -static inline int PyString_FSConverter(PyObject* o, PyObject** p) { - if (o == NULL) { - return 0; - } - - Py_INCREF(o); - *p = o; - return 1; -} - #endif // PYTHON3 static inline char* PyBytes_AsStringAndSize2(PyObject *obj, Py_ssize_t* length) { diff --git a/src/utils.c b/src/utils.c index 5f716128..cdcb182b 100644 --- a/src/utils.c +++ b/src/utils.c @@ -25,7 +25,7 @@ PyObject* PyXmlSec_GetFilePathOrContent(PyObject* file, int* is_content) { return data; } *is_content = 0; - if (!PyString_FSConverter(file, &tmp)) { + if (!PyUnicode_FSConverter(file, &tmp)) { return NULL; } return tmp; From 5055be674a2de83094900591935a096173d74e1d Mon Sep 17 00:00:00 2001 From: "oleg.hoefling" Date: Fri, 28 May 2021 17:48:11 +0200 Subject: [PATCH 7/7] remove python 2 code bits Signed-off-by: oleg.hoefling --- src/constants.c | 7 ------- src/main.c | 51 ------------------------------------------------- src/platform.h | 8 -------- src/template.c | 7 ------- src/tree.c | 7 ------- 5 files changed, 80 deletions(-) diff --git a/src/constants.c b/src/constants.c index 938d5834..8c17e389 100644 --- a/src/constants.c +++ b/src/constants.c @@ -245,7 +245,6 @@ static PyObject* PyXmlSec_KeyDataNew(xmlSecKeyDataId id) { return (PyObject*)keydata; } -#ifdef PY3K static PyModuleDef PyXmlSec_ConstantsModule = { PyModuleDef_HEAD_INIT, @@ -253,7 +252,6 @@ static PyModuleDef PyXmlSec_ConstantsModule = PYXMLSEC_CONSTANTS_DOC, -1, NULL, NULL, NULL, NULL, NULL }; -#endif // PY3K // initialize constants module and registers it base package int PyXmlSec_ConstantsModule_Init(PyObject* package) { @@ -267,12 +265,7 @@ int PyXmlSec_ConstantsModule_Init(PyObject* package) { PyObject* keyDataTypeCls = NULL; PyObject* tmp = NULL; -#ifdef PY3K constants = PyModule_Create(&PyXmlSec_ConstantsModule); -#else - constants = Py_InitModule3(STRINGIFY(MODULE_NAME) ".constants", NULL, PYXMLSEC_CONSTANTS_DOC); - Py_XINCREF(constants); -#endif if (!constants) return -1; diff --git a/src/main.c b/src/main.c index c097d7f5..a602982c 100644 --- a/src/main.c +++ b/src/main.c @@ -203,8 +203,6 @@ int PyXmlSec_EncModule_Init(PyObject* package); // templates management int PyXmlSec_TemplateModule_Init(PyObject* package); -#ifdef PY3K - static int PyXmlSec_PyClear(PyObject *self) { PyXmlSec_Free(free_mode); return 0; @@ -225,54 +223,12 @@ static PyModuleDef PyXmlSecModule = { #define PYENTRY_FUNC_NAME JOIN(PyInit_, MODULE_NAME) #define PY_MOD_RETURN(m) return m -#else // PY3K -#define PYENTRY_FUNC_NAME JOIN(init, MODULE_NAME) -#define PY_MOD_RETURN(m) return - -static void PyXmlSec_PyModuleGuard__del__(PyObject* self) -{ - PyXmlSec_Free(free_mode); - Py_TYPE(self)->tp_free(self); -} - -// we need guard to free resources on module unload -typedef struct { - PyObject_HEAD -} PyXmlSec_PyModuleGuard; - -static PyTypeObject PyXmlSec_PyModuleGuardType = { - PyVarObject_HEAD_INIT(NULL, 0) - STRINGIFY(MODULE_NAME) "__Guard", /* tp_name */ - sizeof(PyXmlSec_PyModuleGuard), /* tp_basicsize */ - 0, /* tp_itemsize */ - PyXmlSec_PyModuleGuard__del__, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ -}; -#endif // PY3K PyMODINIT_FUNC PYENTRY_FUNC_NAME(void) { PyObject *module = NULL; -#ifdef PY3K module = PyModule_Create(&PyXmlSecModule); -#else - module = Py_InitModule3(STRINGIFY(MODULE_NAME), PyXmlSec_MainMethods, MODULE_DOC); -#endif if (!module) { PY_MOD_RETURN(NULL); /* this really should never happen */ } @@ -294,13 +250,6 @@ PYENTRY_FUNC_NAME(void) if (PyXmlSec_EncModule_Init(module) < 0) goto ON_FAIL; if (PyXmlSec_TemplateModule_Init(module) < 0) goto ON_FAIL; -#ifndef PY3K - if (PyType_Ready(&PyXmlSec_PyModuleGuardType) < 0) goto ON_FAIL; - PYXMLSEC_DEBUGF("%p", &PyXmlSec_PyModuleGuardType); - // added guard to free resources on module unload, this should be called after last - if (PyModule_AddObject(module, "__guard", _PyObject_New(&PyXmlSec_PyModuleGuardType)) < 0) goto ON_FAIL; -#endif - PY_MOD_RETURN(module); ON_FAIL: PY_MOD_RETURN(NULL); diff --git a/src/platform.h b/src/platform.h index 35705f2d..35163e88 100644 --- a/src/platform.h +++ b/src/platform.h @@ -35,14 +35,6 @@ typedef int Py_ssize_t; #define PY_SSIZE_T_MIN INT_MIN #endif -#if PY_MAJOR_VERSION >= 3 -#define PY3K 1 -#else // PY3K - -#define PyBytes_AsStringAndSize PyString_AsStringAndSize - -#endif // PYTHON3 - static inline char* PyBytes_AsStringAndSize2(PyObject *obj, Py_ssize_t* length) { char* buffer = NULL; return ((PyBytes_AsStringAndSize(obj, &buffer, length) < 0) ? (char*)(0) : buffer); diff --git a/src/template.c b/src/template.c index 0d35832b..ae0eca34 100644 --- a/src/template.c +++ b/src/template.c @@ -918,7 +918,6 @@ static PyMethodDef PyXmlSec_TemplateMethods[] = { {NULL, NULL} /* sentinel */ }; -#ifdef PY3K static PyModuleDef PyXmlSec_TemplateModule = { PyModuleDef_HEAD_INIT, @@ -931,15 +930,9 @@ static PyModuleDef PyXmlSec_TemplateModule = NULL, /* m_clear */ NULL, /* m_free */ }; -#endif // PY3K int PyXmlSec_TemplateModule_Init(PyObject* package) { -#ifdef PY3K PyObject* template = PyModule_Create(&PyXmlSec_TemplateModule); -#else - PyObject* template = Py_InitModule3(STRINGIFY(MODULE_NAME) ".template", PyXmlSec_TemplateMethods, PYXMLSEC_TEMPLATES_DOC); - Py_XINCREF(template); -#endif if (!template) goto ON_FAIL; PYXMLSEC_DEBUGF("%p", template); diff --git a/src/tree.c b/src/tree.c index df8821c3..37cae785 100644 --- a/src/tree.c +++ b/src/tree.c @@ -230,7 +230,6 @@ static PyMethodDef PyXmlSec_TreeMethods[] = { {NULL, NULL} /* sentinel */ }; -#ifdef PY3K static PyModuleDef PyXmlSec_TreeModule = { PyModuleDef_HEAD_INIT, @@ -243,16 +242,10 @@ static PyModuleDef PyXmlSec_TreeModule = NULL, /* m_clear */ NULL, /* m_free */ }; -#endif // PY3K int PyXmlSec_TreeModule_Init(PyObject* package) { -#ifdef PY3K PyObject* tree = PyModule_Create(&PyXmlSec_TreeModule); -#else - PyObject* tree = Py_InitModule3(STRINGIFY(MODULE_NAME) ".tree", PyXmlSec_TreeMethods, PYXMLSEC_TREE_DOC); - Py_XINCREF(tree); -#endif if (!tree) goto ON_FAIL;