Skip to content

Commit 5055be6

Browse files
committed
remove python 2 code bits
Signed-off-by: oleg.hoefling <[email protected]>
1 parent cfe61ea commit 5055be6

File tree

5 files changed

+0
-80
lines changed

5 files changed

+0
-80
lines changed

src/constants.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,13 @@ static PyObject* PyXmlSec_KeyDataNew(xmlSecKeyDataId id) {
245245
return (PyObject*)keydata;
246246
}
247247

248-
#ifdef PY3K
249248
static PyModuleDef PyXmlSec_ConstantsModule =
250249
{
251250
PyModuleDef_HEAD_INIT,
252251
STRINGIFY(MODULE_NAME) ".constants",
253252
PYXMLSEC_CONSTANTS_DOC,
254253
-1, NULL, NULL, NULL, NULL, NULL
255254
};
256-
#endif // PY3K
257255

258256
// initialize constants module and registers it base package
259257
int PyXmlSec_ConstantsModule_Init(PyObject* package) {
@@ -267,12 +265,7 @@ int PyXmlSec_ConstantsModule_Init(PyObject* package) {
267265
PyObject* keyDataTypeCls = NULL;
268266
PyObject* tmp = NULL;
269267

270-
#ifdef PY3K
271268
constants = PyModule_Create(&PyXmlSec_ConstantsModule);
272-
#else
273-
constants = Py_InitModule3(STRINGIFY(MODULE_NAME) ".constants", NULL, PYXMLSEC_CONSTANTS_DOC);
274-
Py_XINCREF(constants);
275-
#endif
276269

277270
if (!constants) return -1;
278271

src/main.c

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ int PyXmlSec_EncModule_Init(PyObject* package);
203203
// templates management
204204
int PyXmlSec_TemplateModule_Init(PyObject* package);
205205

206-
#ifdef PY3K
207-
208206
static int PyXmlSec_PyClear(PyObject *self) {
209207
PyXmlSec_Free(free_mode);
210208
return 0;
@@ -225,54 +223,12 @@ static PyModuleDef PyXmlSecModule = {
225223

226224
#define PYENTRY_FUNC_NAME JOIN(PyInit_, MODULE_NAME)
227225
#define PY_MOD_RETURN(m) return m
228-
#else // PY3K
229-
#define PYENTRY_FUNC_NAME JOIN(init, MODULE_NAME)
230-
#define PY_MOD_RETURN(m) return
231-
232-
static void PyXmlSec_PyModuleGuard__del__(PyObject* self)
233-
{
234-
PyXmlSec_Free(free_mode);
235-
Py_TYPE(self)->tp_free(self);
236-
}
237-
238-
// we need guard to free resources on module unload
239-
typedef struct {
240-
PyObject_HEAD
241-
} PyXmlSec_PyModuleGuard;
242-
243-
static PyTypeObject PyXmlSec_PyModuleGuardType = {
244-
PyVarObject_HEAD_INIT(NULL, 0)
245-
STRINGIFY(MODULE_NAME) "__Guard", /* tp_name */
246-
sizeof(PyXmlSec_PyModuleGuard), /* tp_basicsize */
247-
0, /* tp_itemsize */
248-
PyXmlSec_PyModuleGuard__del__, /* tp_dealloc */
249-
0, /* tp_print */
250-
0, /* tp_getattr */
251-
0, /* tp_setattr */
252-
0, /* tp_reserved */
253-
0, /* tp_repr */
254-
0, /* tp_as_number */
255-
0, /* tp_as_sequence */
256-
0, /* tp_as_mapping */
257-
0, /* tp_hash */
258-
0, /* tp_call */
259-
0, /* tp_str */
260-
0, /* tp_getattro */
261-
0, /* tp_setattro */
262-
0, /* tp_as_buffer */
263-
Py_TPFLAGS_DEFAULT, /* tp_flags */
264-
};
265-
#endif // PY3K
266226

267227
PyMODINIT_FUNC
268228
PYENTRY_FUNC_NAME(void)
269229
{
270230
PyObject *module = NULL;
271-
#ifdef PY3K
272231
module = PyModule_Create(&PyXmlSecModule);
273-
#else
274-
module = Py_InitModule3(STRINGIFY(MODULE_NAME), PyXmlSec_MainMethods, MODULE_DOC);
275-
#endif
276232
if (!module) {
277233
PY_MOD_RETURN(NULL); /* this really should never happen */
278234
}
@@ -294,13 +250,6 @@ PYENTRY_FUNC_NAME(void)
294250
if (PyXmlSec_EncModule_Init(module) < 0) goto ON_FAIL;
295251
if (PyXmlSec_TemplateModule_Init(module) < 0) goto ON_FAIL;
296252

297-
#ifndef PY3K
298-
if (PyType_Ready(&PyXmlSec_PyModuleGuardType) < 0) goto ON_FAIL;
299-
PYXMLSEC_DEBUGF("%p", &PyXmlSec_PyModuleGuardType);
300-
// added guard to free resources on module unload, this should be called after last
301-
if (PyModule_AddObject(module, "__guard", _PyObject_New(&PyXmlSec_PyModuleGuardType)) < 0) goto ON_FAIL;
302-
#endif
303-
304253
PY_MOD_RETURN(module);
305254
ON_FAIL:
306255
PY_MOD_RETURN(NULL);

src/platform.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,6 @@ typedef int Py_ssize_t;
3535
#define PY_SSIZE_T_MIN INT_MIN
3636
#endif
3737

38-
#if PY_MAJOR_VERSION >= 3
39-
#define PY3K 1
40-
#else // PY3K
41-
42-
#define PyBytes_AsStringAndSize PyString_AsStringAndSize
43-
44-
#endif // PYTHON3
45-
4638
static inline char* PyBytes_AsStringAndSize2(PyObject *obj, Py_ssize_t* length) {
4739
char* buffer = NULL;
4840
return ((PyBytes_AsStringAndSize(obj, &buffer, length) < 0) ? (char*)(0) : buffer);

src/template.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,6 @@ static PyMethodDef PyXmlSec_TemplateMethods[] = {
918918
{NULL, NULL} /* sentinel */
919919
};
920920

921-
#ifdef PY3K
922921
static PyModuleDef PyXmlSec_TemplateModule =
923922
{
924923
PyModuleDef_HEAD_INIT,
@@ -931,15 +930,9 @@ static PyModuleDef PyXmlSec_TemplateModule =
931930
NULL, /* m_clear */
932931
NULL, /* m_free */
933932
};
934-
#endif // PY3K
935933

936934
int PyXmlSec_TemplateModule_Init(PyObject* package) {
937-
#ifdef PY3K
938935
PyObject* template = PyModule_Create(&PyXmlSec_TemplateModule);
939-
#else
940-
PyObject* template = Py_InitModule3(STRINGIFY(MODULE_NAME) ".template", PyXmlSec_TemplateMethods, PYXMLSEC_TEMPLATES_DOC);
941-
Py_XINCREF(template);
942-
#endif
943936

944937
if (!template) goto ON_FAIL;
945938
PYXMLSEC_DEBUGF("%p", template);

src/tree.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ static PyMethodDef PyXmlSec_TreeMethods[] = {
230230
{NULL, NULL} /* sentinel */
231231
};
232232

233-
#ifdef PY3K
234233
static PyModuleDef PyXmlSec_TreeModule =
235234
{
236235
PyModuleDef_HEAD_INIT,
@@ -243,16 +242,10 @@ static PyModuleDef PyXmlSec_TreeModule =
243242
NULL, /* m_clear */
244243
NULL, /* m_free */
245244
};
246-
#endif // PY3K
247245

248246

249247
int PyXmlSec_TreeModule_Init(PyObject* package) {
250-
#ifdef PY3K
251248
PyObject* tree = PyModule_Create(&PyXmlSec_TreeModule);
252-
#else
253-
PyObject* tree = Py_InitModule3(STRINGIFY(MODULE_NAME) ".tree", PyXmlSec_TreeMethods, PYXMLSEC_TREE_DOC);
254-
Py_XINCREF(tree);
255-
#endif
256249

257250
if (!tree) goto ON_FAIL;
258251

0 commit comments

Comments
 (0)