summaryrefslogtreecommitdiffstats
path: root/Modules/clinic/pyexpat.c.h
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/clinic/pyexpat.c.h')
-rw-r--r--Modules/clinic/pyexpat.c.h70
1 files changed, 62 insertions, 8 deletions
diff --git a/Modules/clinic/pyexpat.c.h b/Modules/clinic/pyexpat.c.h
index 1545485..3fe7b64 100644
--- a/Modules/clinic/pyexpat.c.h
+++ b/Modules/clinic/pyexpat.c.h
@@ -24,10 +24,23 @@ pyexpat_xmlparser_Parse(xmlparseobject *self, PyObject *const *args, Py_ssize_t
PyObject *data;
int isfinal = 0;
- if (!_PyArg_ParseStack(args, nargs, "O|i:Parse",
- &data, &isfinal)) {
+ if (!_PyArg_CheckPositional("Parse", nargs, 1, 2)) {
goto exit;
}
+ data = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ isfinal = _PyLong_AsInt(args[1]);
+ if (isfinal == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional:
return_value = pyexpat_xmlparser_Parse_impl(self, data, isfinal);
exit:
@@ -62,7 +75,7 @@ pyexpat_xmlparser_SetBase(xmlparseobject *self, PyObject *arg)
const char *base;
if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("SetBase", "str", arg);
+ _PyArg_BadArgument("SetBase", 0, "str", arg);
goto exit;
}
Py_ssize_t base_length;
@@ -140,10 +153,44 @@ pyexpat_xmlparser_ExternalEntityParserCreate(xmlparseobject *self, PyObject *con
const char *context;
const char *encoding = NULL;
- if (!_PyArg_ParseStack(args, nargs, "z|s:ExternalEntityParserCreate",
- &context, &encoding)) {
+ if (!_PyArg_CheckPositional("ExternalEntityParserCreate", nargs, 1, 2)) {
+ goto exit;
+ }
+ if (args[0] == Py_None) {
+ context = NULL;
+ }
+ else if (PyUnicode_Check(args[0])) {
+ Py_ssize_t context_length;
+ context = PyUnicode_AsUTF8AndSize(args[0], &context_length);
+ if (context == NULL) {
+ goto exit;
+ }
+ if (strlen(context) != (size_t)context_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("ExternalEntityParserCreate", 1, "str or None", args[0]);
goto exit;
}
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (!PyUnicode_Check(args[1])) {
+ _PyArg_BadArgument("ExternalEntityParserCreate", 2, "str", args[1]);
+ goto exit;
+ }
+ Py_ssize_t encoding_length;
+ encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length);
+ if (encoding == NULL) {
+ goto exit;
+ }
+ if (strlen(encoding) != (size_t)encoding_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+skip_optional:
return_value = pyexpat_xmlparser_ExternalEntityParserCreate_impl(self, context, encoding);
exit:
@@ -212,10 +259,17 @@ pyexpat_xmlparser_UseForeignDTD(xmlparseobject *self, PyObject *const *args, Py_
PyObject *return_value = NULL;
int flag = 1;
- if (!_PyArg_ParseStack(args, nargs, "|p:UseForeignDTD",
- &flag)) {
+ if (!_PyArg_CheckPositional("UseForeignDTD", nargs, 0, 1)) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ flag = PyObject_IsTrue(args[0]);
+ if (flag < 0) {
goto exit;
}
+skip_optional:
return_value = pyexpat_xmlparser_UseForeignDTD_impl(self, flag);
exit:
@@ -294,4 +348,4 @@ exit:
#ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */
-/*[clinic end generated code: output=d3750256eb0da1cb input=a9049054013a1b77]*/
+/*[clinic end generated code: output=0f18b756d82b78a5 input=a9049054013a1b77]*/