summaryrefslogtreecommitdiffstats
path: root/Modules/pyexpat.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/pyexpat.c')
-rw-r--r--Modules/pyexpat.c53
1 files changed, 19 insertions, 34 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index fe50e36..8a10bab 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -981,16 +981,12 @@ PyDoc_STRVAR(xmlparse_ParseFile__doc__,
Parse XML data from file-like object.");
static PyObject *
-xmlparse_ParseFile(xmlparseobject *self, PyObject *args)
+xmlparse_ParseFile(xmlparseobject *self, PyObject *f)
{
int rv = 1;
- PyObject *f;
FILE *fp;
PyObject *readmethod = NULL;
- if (!PyArg_ParseTuple(args, "O:ParseFile", &f))
- return NULL;
-
if (PyFile_Check(f)) {
fp = PyFile_AsFile(f);
}
@@ -1062,11 +1058,8 @@ PyDoc_STRVAR(xmlparse_GetBase__doc__,
Return base URL string for the parser.");
static PyObject *
-xmlparse_GetBase(xmlparseobject *self, PyObject *args)
+xmlparse_GetBase(xmlparseobject *self, PyObject *unused)
{
- if (!PyArg_ParseTuple(args, ":GetBase"))
- return NULL;
-
return Py_BuildValue("z", XML_GetBase(self->itself));
}
@@ -1077,29 +1070,21 @@ If the event was generated by a large amount of text (such as a start tag\n\
for an element with many attributes), not all of the text may be available.");
static PyObject *
-xmlparse_GetInputContext(xmlparseobject *self, PyObject *args)
+xmlparse_GetInputContext(xmlparseobject *self, PyObject *unused)
{
- PyObject *result = NULL;
-
- if (PyArg_ParseTuple(args, ":GetInputContext")) {
- if (self->in_callback) {
- int offset, size;
- const char *buffer
- = XML_GetInputContext(self->itself, &offset, &size);
-
- if (buffer != NULL)
- result = PyString_FromStringAndSize(buffer + offset, size - offset);
- else {
- result = Py_None;
- Py_INCREF(result);
- }
- }
- else {
- result = Py_None;
- Py_INCREF(result);
- }
+ if (self->in_callback) {
+ int offset, size;
+ const char *buffer
+ = XML_GetInputContext(self->itself, &offset, &size);
+
+ if (buffer != NULL)
+ return PyString_FromStringAndSize(buffer + offset,
+ size - offset);
+ else
+ Py_RETURN_NONE;
}
- return result;
+ else
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(xmlparse_ExternalEntityParserCreate__doc__,
@@ -1228,7 +1213,7 @@ xmlparse_UseForeignDTD(xmlparseobject *self, PyObject *args)
PyObject *flagobj = NULL;
XML_Bool flag = XML_TRUE;
enum XML_Error rc;
- if (!PyArg_ParseTuple(args, "|O:UseForeignDTD", &flagobj))
+ if (!PyArg_UnpackTuple(args, "UseForeignDTD", 0, 1, &flagobj))
return NULL;
if (flagobj != NULL)
flag = PyObject_IsTrue(flagobj) ? XML_TRUE : XML_FALSE;
@@ -1245,17 +1230,17 @@ static struct PyMethodDef xmlparse_methods[] = {
{"Parse", (PyCFunction)xmlparse_Parse,
METH_VARARGS, xmlparse_Parse__doc__},
{"ParseFile", (PyCFunction)xmlparse_ParseFile,
- METH_VARARGS, xmlparse_ParseFile__doc__},
+ METH_O, xmlparse_ParseFile__doc__},
{"SetBase", (PyCFunction)xmlparse_SetBase,
METH_VARARGS, xmlparse_SetBase__doc__},
{"GetBase", (PyCFunction)xmlparse_GetBase,
- METH_VARARGS, xmlparse_GetBase__doc__},
+ METH_NOARGS, xmlparse_GetBase__doc__},
{"ExternalEntityParserCreate", (PyCFunction)xmlparse_ExternalEntityParserCreate,
METH_VARARGS, xmlparse_ExternalEntityParserCreate__doc__},
{"SetParamEntityParsing", (PyCFunction)xmlparse_SetParamEntityParsing,
METH_VARARGS, xmlparse_SetParamEntityParsing__doc__},
{"GetInputContext", (PyCFunction)xmlparse_GetInputContext,
- METH_VARARGS, xmlparse_GetInputContext__doc__},
+ METH_NOARGS, xmlparse_GetInputContext__doc__},
#if XML_COMBINED_VERSION >= 19505
{"UseForeignDTD", (PyCFunction)xmlparse_UseForeignDTD,
METH_VARARGS, xmlparse_UseForeignDTD__doc__},