Skip to content

Commit 84b3700

Browse files
committed
pytrap: remove python2 checks
1 parent c3a4d96 commit 84b3700

File tree

2 files changed

+1
-40
lines changed

2 files changed

+1
-40
lines changed

pytrap/src/pytrapmodule.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -847,8 +847,6 @@ static PyMethodDef pytrap_methods[] = {
847847
"For more details, see the generated documentation:\n" \
848848
"https://nemea.liberouter.org/doc/pytrap/.\n"
849849

850-
#if PY_MAJOR_VERSION >= 3
851-
852850
static struct PyModuleDef pytrapmodule = {
853851
PyModuleDef_HEAD_INIT,
854852
"pytrap.pytrap", /* name of module */
@@ -861,20 +859,10 @@ static struct PyModuleDef pytrapmodule = {
861859

862860
PyMODINIT_FUNC
863861
PyInit_pytrap(void)
864-
#else
865-
# define INITERROR return
866-
867-
void
868-
initpytrap(void)
869-
#endif
870862
{
871863
PyObject *m;
872864

873-
#if PY_MAJOR_VERSION >= 3
874865
m = PyModule_Create(&pytrapmodule);
875-
#else
876-
m = Py_InitModule3("pytrap.pytrap", pytrap_methods, DOCSTRING_MODULE);
877-
#endif
878866
if (m == NULL) {
879867
INITERROR;
880868
}
@@ -941,8 +929,5 @@ initpytrap(void)
941929
PyModule_AddIntConstant(m, "VERB_VERBOSE2", 1);
942930
PyModule_AddIntConstant(m, "VERB_VERBOSE3", 2);
943931

944-
945-
#if PY_MAJOR_VERSION >= 3
946932
return m;
947-
#endif
948933
}

pytrap/src/unirecmodule.c

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,6 @@ static PyTypeObject pytrap_UnirecTime = {
521521
0, /* tp_setattro */
522522
0, /* tp_as_buffer */
523523
Py_TPFLAGS_DEFAULT |
524-
#if PY_MAJOR_VERSION < 3
525-
Py_TPFLAGS_CHECKTYPES |
526-
#endif
527524
Py_TPFLAGS_BASETYPE, /* tp_flags */
528525
"UnirecTime(int(seconds), [int(miliseconds)])\n"
529526
"UnirecTime(double(secs_and_msecs))\n"
@@ -810,11 +807,7 @@ UnirecTemplate_getByName(pytrap_unirectemplate *self, PyObject *args, PyObject *
810807
return NULL;
811808
}
812809

813-
#if PY_MAJOR_VERSION >= 3
814810
if (!PyUnicode_Check(field_name))
815-
#else
816-
if (!PyUnicode_Check(field_name) && !PyString_Check(field_name))
817-
#endif
818811
{
819812
PyErr_SetString(PyExc_TypeError, "Argument field_name must be string.");
820813
return NULL;
@@ -1424,12 +1417,7 @@ UnirecTemplate_set(pytrap_unirectemplate *self, PyObject *args, PyObject *keywds
14241417
return NULL;
14251418
}
14261419

1427-
#if PY_MAJOR_VERSION >= 3
1428-
if (!PyUnicode_Check(field_name))
1429-
#else
1430-
if (!PyUnicode_Check(field_name) && !PyString_Check(field_name))
1431-
#endif
1432-
{
1420+
if (!PyUnicode_Check(field_name)) {
14331421
PyErr_SetString(PyExc_TypeError, "Argument field_name must be string.");
14341422
return NULL;
14351423
}
@@ -1451,11 +1439,7 @@ UnirecTemplate_getFieldsDict_local(pytrap_unirectemplate *self, char byId)
14511439
PyObject *d = PyDict_New();
14521440
if (d != NULL) {
14531441
for (i = 0; i < self->urtmplt->count; i++) {
1454-
#if PY_MAJOR_VERSION >= 3
14551442
key = PyUnicode_FromString(ur_get_name(self->urtmplt->ids[i]));
1456-
#else
1457-
key = PyString_FromString(ur_get_name(self->urtmplt->ids[i]));
1458-
#endif
14591443
num = PyLong_FromLong(self->urtmplt->ids[i]);
14601444
if (byId) {
14611445
result = PyDict_SetItem(d, num, key);
@@ -2116,11 +2100,7 @@ UnirecTemplate_str(pytrap_unirectemplate *self)
21162100
{
21172101
char *s = ur_template_string_delimiter(self->urtmplt, ',');
21182102
PyObject *result;
2119-
#if PY_MAJOR_VERSION >= 3
21202103
result = PyUnicode_FromFormat("(%s)", s);
2121-
#else
2122-
result = PyString_FromFormat("(%s)", s);
2123-
#endif
21242104
free(s);
21252105
return result;
21262106
}
@@ -2167,11 +2147,7 @@ UnirecTemplate_next(pytrap_unirectemplate *self)
21672147
PyObject *result;
21682148

21692149
if (self->iter_index < self->field_count) {
2170-
#if PY_MAJOR_VERSION >= 3
21712150
name = PyUnicode_FromString(ur_get_name(self->urtmplt->ids[self->iter_index]));
2172-
#else
2173-
name = PyString_FromString(ur_get_name(self->urtmplt->ids[self->iter_index]));
2174-
#endif
21752151
value = UnirecTemplate_get_local(self, self->data, self->urtmplt->ids[self->iter_index]);
21762152
self->iter_index++;
21772153
result = Py_BuildValue("(OO)", name, value);

0 commit comments

Comments
 (0)