aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Modules/_sre.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_sre.c')
-rw-r--r--Modules/_sre.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/Modules/_sre.c b/Modules/_sre.c
index 09b58352de4..0a62f62dc65 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -35,7 +35,7 @@
* other compatibility work.
*/
-static char copyright[] =
+static const char copyright[] =
" SRE 2.2.2 Copyright (c) 1997-2002 by Secret Labs AB ";
#define PY_SSIZE_T_CLEAN
@@ -62,9 +62,6 @@ static char copyright[] =
/* -------------------------------------------------------------------- */
/* optional features */
-/* enables fast searching */
-#define USE_FAST_SEARCH
-
/* enables copy/deepcopy handling (work in progress) */
#undef USE_BUILTIN_COPY
@@ -717,7 +714,7 @@ _sre_SRE_Pattern_search_impl(PatternObject *self, PyObject *string,
}
static PyObject*
-call(char* module, char* function, PyObject* args)
+call(const char* module, const char* function, PyObject* args)
{
PyObject* name;
PyObject* mod;
@@ -1059,7 +1056,6 @@ pattern_subx(PatternObject* self, PyObject* ptemplate, PyObject* string,
PyObject* joiner;
PyObject* item;
PyObject* filter;
- PyObject* args;
PyObject* match;
void* ptr;
Py_ssize_t status;
@@ -1161,13 +1157,7 @@ pattern_subx(PatternObject* self, PyObject* ptemplate, PyObject* string,
match = pattern_new_match(self, &state, 1);
if (!match)
goto error;
- args = PyTuple_Pack(1, match);
- if (!args) {
- Py_DECREF(match);
- goto error;
- }
- item = PyObject_CallObject(filter, args);
- Py_DECREF(args);
+ item = _PyObject_CallArg1(filter, match);
Py_DECREF(match);
if (!item)
goto error;
@@ -2052,8 +2042,9 @@ match_getindex(MatchObject* self, PyObject* index)
/* Default value */
return 0;
- if (PyLong_Check(index))
- return PyLong_AsSsize_t(index);
+ if (PyIndex_Check(index)) {
+ return PyNumber_AsSsize_t(index, NULL);
+ }
i = -1;