diff --git a/src/fuzzysearch/_c_ext_base.h b/src/fuzzysearch/_c_ext_base.h index ffe3083..d94c5cb 100644 --- a/src/fuzzysearch/_c_ext_base.h +++ b/src/fuzzysearch/_c_ext_base.h @@ -4,10 +4,6 @@ #define PY_SSIZE_T_CLEAN #include -#if PY_MAJOR_VERSION >= 3 -#define IS_PY3K -#endif - #ifndef unlikely #ifdef __GNUC__ /* Test for GCC > 2.95 */ diff --git a/src/fuzzysearch/_common.c b/src/fuzzysearch/_common.c index 5aca022..23b6a5a 100644 --- a/src/fuzzysearch/_common.c +++ b/src/fuzzysearch/_common.c @@ -18,12 +18,7 @@ search_exact_byteslike(PyObject *self, PyObject *args, PyObject *kwdict) { int subseq_sum; char *next_match_ptr; - const char* argspec = -#ifdef IS_PY3K - "y*y*|ll:search_exact_byteslike"; -#else - "s*s*|ll:search_exact_byteslike"; -#endif + const char* argspec = "y*y*|ll:search_exact_byteslike"; if (unlikely(!PyArg_ParseTupleAndKeywords( args, kwdict, @@ -88,11 +83,7 @@ search_exact_byteslike(PyObject *self, PyObject *args, PyObject *kwdict) { while (next_match_ptr != NULL) { next_match_index = (const char *)next_match_ptr - seq; -#ifdef IS_PY3K next_result = PyLong_FromLong(next_match_index + start_index); -#else - next_result = PyInt_FromLong(next_match_index + start_index); -#endif if (unlikely(next_result == NULL)) { Py_DECREF(results); goto error; @@ -133,12 +124,7 @@ count_differences_with_maximum_byteslike(PyObject *self, PyObject *args) Py_ssize_t i; int n_differences; - const char* argspec = -#ifdef IS_PY3K - "y*y*i"; -#else - "s*s*i"; -#endif + const char* argspec = "y*y*i"; if (!PyArg_ParseTuple( args, @@ -197,8 +183,6 @@ static PyMethodDef _common_methods[] = { }; -#ifdef IS_PY3K - static struct PyModuleDef _common_module = { PyModuleDef_HEAD_INIT, "_common", /* name of module */ @@ -213,13 +197,3 @@ PyInit__common(void) { return PyModule_Create(&_common_module); } - -#else - -PyMODINIT_FUNC -init_common(void) -{ - (void) Py_InitModule("_common", _common_methods); -} - -#endif diff --git a/src/fuzzysearch/_pymemmem.c b/src/fuzzysearch/_pymemmem.c index fdc2657..534d32f 100644 --- a/src/fuzzysearch/_pymemmem.c +++ b/src/fuzzysearch/_pymemmem.c @@ -2,11 +2,6 @@ #include "src/fuzzysearch/memmem.h" #include "src/fuzzysearch/wordlen_memmem.h" -#if PY_MAJOR_VERSION >= 3 -#define IS_PY3K -#define PyInt_FromLong PyLong_FromLong -#endif - #ifdef __GNUC__ /* Test for GCC > 2.95 */ @@ -23,16 +18,6 @@ #endif /* __GNUC__ */ -#ifdef IS_PY3K - #define ARG_TYPES_DEF "y#y#" -#else - #if PY_HEX_VERSION >= 0x02070000 - #define ARG_TYPES_DEF "t#t#" - #else - #define ARG_TYPES_DEF "s#s#" - #endif -#endif - static PyObject * py_simple_memmem(PyObject *self, PyObject *args) { /* input params */ @@ -44,7 +29,7 @@ py_simple_memmem(PyObject *self, PyObject *args) { if (unlikely(!PyArg_ParseTuple( args, - ARG_TYPES_DEF, + "y#y#", &needle, &needle_len, &haystack, &haystack_len ))) { @@ -57,7 +42,7 @@ py_simple_memmem(PyObject *self, PyObject *args) { Py_RETURN_NONE; } else { - py_result = PyInt_FromLong(result - haystack); + py_result = PyLong_FromLong(result - haystack); if (unlikely(py_result == NULL)) { return NULL; } @@ -76,7 +61,7 @@ py_wordlen_memmem(PyObject *self, PyObject *args) { if (unlikely(!PyArg_ParseTuple( args, - ARG_TYPES_DEF, + "y#y#", &needle, &needle_len, &haystack, &haystack_len ))) { @@ -89,7 +74,7 @@ py_wordlen_memmem(PyObject *self, PyObject *args) { Py_RETURN_NONE; } else { - py_result = PyInt_FromLong(result - haystack); + py_result = PyLong_FromLong(result - haystack); if (unlikely(py_result == NULL)) { return NULL; } @@ -109,8 +94,6 @@ static PyMethodDef _pymemmem_methods[] = { }; -#ifdef IS_PY3K - static struct PyModuleDef _pymemmem_module = { PyModuleDef_HEAD_INIT, "_pymemmem", /* name of module */ @@ -125,13 +108,3 @@ PyInit__pymemmem(void) { return PyModule_Create(&_pymemmem_module); } - -#else - -PyMODINIT_FUNC -init_pymemmem(void) -{ - (void) Py_InitModule("_pymemmem", _pymemmem_methods); -} - -#endif diff --git a/src/fuzzysearch/_substitutions_only.c b/src/fuzzysearch/_substitutions_only.c index 8135e88..e02170b 100644 --- a/src/fuzzysearch/_substitutions_only.c +++ b/src/fuzzysearch/_substitutions_only.c @@ -17,9 +17,6 @@ #undef DECLARE_VARS -#ifdef IS_PY3K -#define PyInt_FromSsize_t(x) PyLong_FromSsize_t(x) -#endif #define DECLARE_VARS \ PyObject *results; \ PyObject *next_result @@ -28,7 +25,7 @@ if (unlikely(!results)) \ goto error; #define OUTPUT_VALUE(x) do { \ - next_result = PyInt_FromSsize_t((x)); \ + next_result = PyLong_FromSsize_t((x)); \ if (unlikely(next_result == NULL)) { \ Py_DECREF(results); \ goto error; \ @@ -74,8 +71,6 @@ static PyMethodDef substitutions_only_methods[] = { }; -#ifdef IS_PY3K - static struct PyModuleDef substitutions_only_module = { PyModuleDef_HEAD_INIT, "_substitutions_only", /* name of module */ @@ -90,13 +85,3 @@ PyInit__substitutions_only(void) { return PyModule_Create(&substitutions_only_module); } - -#else - -PyMODINIT_FUNC -init_substitutions_only(void) -{ - (void) Py_InitModule("_substitutions_only", substitutions_only_methods); -} - -#endif diff --git a/src/fuzzysearch/_substitutions_only_lp_template.h b/src/fuzzysearch/_substitutions_only_lp_template.h index 1111eca..7da3ff2 100644 --- a/src/fuzzysearch/_substitutions_only_lp_template.h +++ b/src/fuzzysearch/_substitutions_only_lp_template.h @@ -18,12 +18,7 @@ FUNCTION_NAME(PyObject *self, PyObject *args) DECLARE_VARS; - const char* argspec = -#ifdef IS_PY3K - "y*y*i"; -#else - "s*s*i"; -#endif + const char* argspec = "y*y*i"; if (unlikely(!PyArg_ParseTuple( args, diff --git a/src/fuzzysearch/_substitutions_only_ngrams_template.h b/src/fuzzysearch/_substitutions_only_ngrams_template.h index dc65815..462ac01 100644 --- a/src/fuzzysearch/_substitutions_only_ngrams_template.h +++ b/src/fuzzysearch/_substitutions_only_ngrams_template.h @@ -24,12 +24,7 @@ FUNCTION_NAME(PyObject *self, PyObject *args) DECLARE_VARS; - const char* argspec = -#ifdef IS_PY3K - "y*y*i"; -#else - "s*s*i"; -#endif + const char* argspec = "y*y*i"; if (unlikely(!PyArg_ParseTuple( args,