]> granicus.if.org Git - python/commitdiff
Fix C function calling conventions in _sre module.
authorGeorg Brandl <georg@python.org>
Sun, 28 May 2006 22:14:04 +0000 (22:14 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 28 May 2006 22:14:04 +0000 (22:14 +0000)
Modules/_sre.c

index 499eae16dbcfcb6b4cd65cf8b3143ce9cda0f1ae..60940535bab73ed5ee014cf22e9306c2f859be97 100644 (file)
@@ -1623,7 +1623,7 @@ static PyObject*pattern_new_match(PatternObject*, SRE_STATE*, int);
 static PyObject*pattern_scanner(PatternObject*, PyObject*);
 
 static PyObject *
-sre_codesize(PyObject* self, PyObject* args)
+sre_codesize(PyObject* self)
 {
     return Py_BuildValue("i", sizeof(SRE_CODE));
 }
@@ -2467,15 +2467,12 @@ pattern_subn(PatternObject* self, PyObject* args, PyObject* kw)
 }
 
 static PyObject*
-pattern_copy(PatternObject* self, PyObject* args)
+pattern_copy(PatternObject* self)
 {
 #ifdef USE_BUILTIN_COPY
     PatternObject* copy;
     int offset;
 
-    if (args != Py_None && !PyArg_ParseTuple(args, ":__copy__"))
-        return NULL;
-
     copy = PyObject_NEW_VAR(PatternObject, &Pattern_Type, self->codesize);
     if (!copy)
         return NULL;
@@ -2498,16 +2495,12 @@ pattern_copy(PatternObject* self, PyObject* args)
 }
 
 static PyObject*
-pattern_deepcopy(PatternObject* self, PyObject* args)
+pattern_deepcopy(PatternObject* self, PyObject* memo)
 {
 #ifdef USE_BUILTIN_COPY
     PatternObject* copy;
 
-    PyObject* memo;
-    if (!PyArg_ParseTuple(args, "O:__deepcopy__", &memo))
-        return NULL;
-
-    copy = (PatternObject*) pattern_copy(self, Py_None);
+    copy = (PatternObject*) pattern_copy(self);
     if (!copy)
         return NULL;
 
@@ -2578,8 +2571,8 @@ static PyMethodDef pattern_methods[] = {
        pattern_finditer_doc},
 #endif
     {"scanner", (PyCFunction) pattern_scanner, METH_VARARGS},
-    {"__copy__", (PyCFunction) pattern_copy, METH_VARARGS},
-    {"__deepcopy__", (PyCFunction) pattern_deepcopy, METH_VARARGS},
+    {"__copy__", (PyCFunction) pattern_copy, METH_NOARGS},
+    {"__deepcopy__", (PyCFunction) pattern_deepcopy, METH_O},
     {NULL, NULL}
 };
 
@@ -2772,12 +2765,8 @@ match_getslice(MatchObject* self, PyObject* index, PyObject* def)
 }
 
 static PyObject*
-match_expand(MatchObject* self, PyObject* args)
+match_expand(MatchObject* self, PyObject* ptemplate)
 {
-    PyObject* ptemplate;
-    if (!PyArg_ParseTuple(args, "O:expand", &ptemplate))
-        return NULL;
-
     /* delegate to Python code */
     return call(
         SRE_PY_MODULE, "_expand",
@@ -3019,15 +3008,12 @@ match_regs(MatchObject* self)
 }
 
 static PyObject*
-match_copy(MatchObject* self, PyObject* args)
+match_copy(MatchObject* self)
 {
 #ifdef USE_BUILTIN_COPY
     MatchObject* copy;
     int slots, offset;
 
-    if (args != Py_None && !PyArg_ParseTuple(args, ":__copy__"))
-        return NULL;
-
     slots = 2 * (self->pattern->groups+1);
 
     copy = PyObject_NEW_VAR(MatchObject, &Match_Type, slots);
@@ -3053,16 +3039,12 @@ match_copy(MatchObject* self, PyObject* args)
 }
 
 static PyObject*
-match_deepcopy(MatchObject* self, PyObject* args)
+match_deepcopy(MatchObject* self, PyObject* memo)
 {
 #ifdef USE_BUILTIN_COPY
     MatchObject* copy;
 
-    PyObject* memo;
-    if (!PyArg_ParseTuple(args, "O:__deepcopy__", &memo))
-        return NULL;
-
-    copy = (MatchObject*) match_copy(self, Py_None);
+    copy = (MatchObject*) match_copy(self);
     if (!copy)
         return NULL;
 
@@ -3086,9 +3068,9 @@ static PyMethodDef match_methods[] = {
     {"span", (PyCFunction) match_span, METH_VARARGS},
     {"groups", (PyCFunction) match_groups, METH_VARARGS|METH_KEYWORDS},
     {"groupdict", (PyCFunction) match_groupdict, METH_VARARGS|METH_KEYWORDS},
-    {"expand", (PyCFunction) match_expand, METH_VARARGS},
-    {"__copy__", (PyCFunction) match_copy, METH_VARARGS},
-    {"__deepcopy__", (PyCFunction) match_deepcopy, METH_VARARGS},
+    {"expand", (PyCFunction) match_expand, METH_O},
+    {"__copy__", (PyCFunction) match_copy, METH_NOARGS},
+    {"__deepcopy__", (PyCFunction) match_deepcopy, METH_O},
     {NULL, NULL}
 };
 
@@ -3243,7 +3225,7 @@ scanner_dealloc(ScannerObject* self)
 }
 
 static PyObject*
-scanner_match(ScannerObject* self, PyObject* args)
+scanner_match(ScannerObject* self)
 {
     SRE_STATE* state = &self->state;
     PyObject* match;
@@ -3274,7 +3256,7 @@ scanner_match(ScannerObject* self, PyObject* args)
 
 
 static PyObject*
-scanner_search(ScannerObject* self, PyObject* args)
+scanner_search(ScannerObject* self)
 {
     SRE_STATE* state = &self->state;
     PyObject* match;
@@ -3304,10 +3286,8 @@ scanner_search(ScannerObject* self, PyObject* args)
 }
 
 static PyMethodDef scanner_methods[] = {
-    /* FIXME: use METH_OLDARGS instead of 0 or fix to use METH_VARARGS */
-    /*        METH_OLDARGS is not in Python 1.5.2 */
-    {"match", (PyCFunction) scanner_match, 0},
-    {"search", (PyCFunction) scanner_search, 0},
+    {"match", (PyCFunction) scanner_match, METH_NOARGS},
+    {"search", (PyCFunction) scanner_search, METH_NOARGS},
     {NULL, NULL}
 };
 
@@ -3373,7 +3353,7 @@ pattern_scanner(PatternObject* pattern, PyObject* args)
 
 static PyMethodDef _functions[] = {
     {"compile", _compile, METH_VARARGS},
-    {"getcodesize", sre_codesize, METH_VARARGS},
+    {"getcodesize", sre_codesize, METH_NOARGS},
     {"getlower", sre_getlower, METH_VARARGS},
     {NULL, NULL}
 };