summaryrefslogtreecommitdiffstats
path: root/Modules/clinic
diff options
context:
space:
mode:
authorMohamed Koubaa <koubaa.m@gmail.com>2021-01-04 14:34:26 (GMT)
committerGitHub <noreply@github.com>2021-01-04 14:34:26 (GMT)
commitc8a87addb1fa35dec79ed8f227eba3694fc36234 (patch)
tree7c76af255d5abf99836770299764c9af82c44a0c /Modules/clinic
parentbf06b209da8c4ffc07887913f05990fa035aa1fb (diff)
downloadcpython-c8a87addb1fa35dec79ed8f227eba3694fc36234.zip
cpython-c8a87addb1fa35dec79ed8f227eba3694fc36234.tar.gz
cpython-c8a87addb1fa35dec79ed8f227eba3694fc36234.tar.bz2
bpo-1635741: Port pyexpat to multi-phase init (PEP 489) (GH-22222)
Diffstat (limited to 'Modules/clinic')
-rw-r--r--Modules/clinic/pyexpat.c.h119
1 files changed, 50 insertions, 69 deletions
diff --git a/Modules/clinic/pyexpat.c.h b/Modules/clinic/pyexpat.c.h
index 923ca6b..7c56d6a 100644
--- a/Modules/clinic/pyexpat.c.h
+++ b/Modules/clinic/pyexpat.c.h
@@ -11,32 +11,26 @@ PyDoc_STRVAR(pyexpat_xmlparser_Parse__doc__,
"`isfinal\' should be true at end of input.");
#define PYEXPAT_XMLPARSER_PARSE_METHODDEF \
- {"Parse", (PyCFunction)(void(*)(void))pyexpat_xmlparser_Parse, METH_FASTCALL, pyexpat_xmlparser_Parse__doc__},
+ {"Parse", (PyCFunction)(void(*)(void))pyexpat_xmlparser_Parse, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_Parse__doc__},
static PyObject *
-pyexpat_xmlparser_Parse_impl(xmlparseobject *self, PyObject *data,
- int isfinal);
+pyexpat_xmlparser_Parse_impl(xmlparseobject *self, PyTypeObject *cls,
+ PyObject *data, int isfinal);
static PyObject *
-pyexpat_xmlparser_Parse(xmlparseobject *self, PyObject *const *args, Py_ssize_t nargs)
+pyexpat_xmlparser_Parse(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"", "", NULL};
+ static _PyArg_Parser _parser = {"O|i:Parse", _keywords, 0};
PyObject *data;
int isfinal = 0;
- if (!_PyArg_CheckPositional("Parse", nargs, 1, 2)) {
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
+ &data, &isfinal)) {
goto exit;
}
- data = args[0];
- if (nargs < 2) {
- goto skip_optional;
- }
- isfinal = _PyLong_AsInt(args[1]);
- if (isfinal == -1 && PyErr_Occurred()) {
- goto exit;
- }
-skip_optional:
- return_value = pyexpat_xmlparser_Parse_impl(self, data, isfinal);
+ return_value = pyexpat_xmlparser_Parse_impl(self, cls, data, isfinal);
exit:
return return_value;
@@ -49,7 +43,29 @@ PyDoc_STRVAR(pyexpat_xmlparser_ParseFile__doc__,
"Parse XML data from file-like object.");
#define PYEXPAT_XMLPARSER_PARSEFILE_METHODDEF \
- {"ParseFile", (PyCFunction)pyexpat_xmlparser_ParseFile, METH_O, pyexpat_xmlparser_ParseFile__doc__},
+ {"ParseFile", (PyCFunction)(void(*)(void))pyexpat_xmlparser_ParseFile, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_ParseFile__doc__},
+
+static PyObject *
+pyexpat_xmlparser_ParseFile_impl(xmlparseobject *self, PyTypeObject *cls,
+ PyObject *file);
+
+static PyObject *
+pyexpat_xmlparser_ParseFile(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"", NULL};
+ static _PyArg_Parser _parser = {"O:ParseFile", _keywords, 0};
+ PyObject *file;
+
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
+ &file)) {
+ goto exit;
+ }
+ return_value = pyexpat_xmlparser_ParseFile_impl(self, cls, file);
+
+exit:
+ return return_value;
+}
PyDoc_STRVAR(pyexpat_xmlparser_SetBase__doc__,
"SetBase($self, base, /)\n"
@@ -135,59 +151,28 @@ PyDoc_STRVAR(pyexpat_xmlparser_ExternalEntityParserCreate__doc__,
"Create a parser for parsing an external entity based on the information passed to the ExternalEntityRefHandler.");
#define PYEXPAT_XMLPARSER_EXTERNALENTITYPARSERCREATE_METHODDEF \
- {"ExternalEntityParserCreate", (PyCFunction)(void(*)(void))pyexpat_xmlparser_ExternalEntityParserCreate, METH_FASTCALL, pyexpat_xmlparser_ExternalEntityParserCreate__doc__},
+ {"ExternalEntityParserCreate", (PyCFunction)(void(*)(void))pyexpat_xmlparser_ExternalEntityParserCreate, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_ExternalEntityParserCreate__doc__},
static PyObject *
pyexpat_xmlparser_ExternalEntityParserCreate_impl(xmlparseobject *self,
+ PyTypeObject *cls,
const char *context,
const char *encoding);
static PyObject *
-pyexpat_xmlparser_ExternalEntityParserCreate(xmlparseobject *self, PyObject *const *args, Py_ssize_t nargs)
+pyexpat_xmlparser_ExternalEntityParserCreate(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"", "", NULL};
+ static _PyArg_Parser _parser = {"z|s:ExternalEntityParserCreate", _keywords, 0};
const char *context;
const char *encoding = NULL;
- if (!_PyArg_CheckPositional("ExternalEntityParserCreate", nargs, 1, 2)) {
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
+ &context, &encoding)) {
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", "argument 1", "str or None", args[0]);
- goto exit;
- }
- if (nargs < 2) {
- goto skip_optional;
- }
- if (!PyUnicode_Check(args[1])) {
- _PyArg_BadArgument("ExternalEntityParserCreate", "argument 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);
+ return_value = pyexpat_xmlparser_ExternalEntityParserCreate_impl(self, cls, context, encoding);
exit:
return return_value;
@@ -239,29 +224,25 @@ PyDoc_STRVAR(pyexpat_xmlparser_UseForeignDTD__doc__,
"information to the parser. \'flag\' defaults to True if not provided.");
#define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF \
- {"UseForeignDTD", (PyCFunction)(void(*)(void))pyexpat_xmlparser_UseForeignDTD, METH_FASTCALL, pyexpat_xmlparser_UseForeignDTD__doc__},
+ {"UseForeignDTD", (PyCFunction)(void(*)(void))pyexpat_xmlparser_UseForeignDTD, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_UseForeignDTD__doc__},
static PyObject *
-pyexpat_xmlparser_UseForeignDTD_impl(xmlparseobject *self, int flag);
+pyexpat_xmlparser_UseForeignDTD_impl(xmlparseobject *self, PyTypeObject *cls,
+ int flag);
static PyObject *
-pyexpat_xmlparser_UseForeignDTD(xmlparseobject *self, PyObject *const *args, Py_ssize_t nargs)
+pyexpat_xmlparser_UseForeignDTD(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"", NULL};
+ static _PyArg_Parser _parser = {"|p:UseForeignDTD", _keywords, 0};
int flag = 1;
- if (!_PyArg_CheckPositional("UseForeignDTD", nargs, 0, 1)) {
- goto exit;
- }
- if (nargs < 1) {
- goto skip_optional;
- }
- flag = PyObject_IsTrue(args[0]);
- if (flag < 0) {
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
+ &flag)) {
goto exit;
}
-skip_optional:
- return_value = pyexpat_xmlparser_UseForeignDTD_impl(self, flag);
+ return_value = pyexpat_xmlparser_UseForeignDTD_impl(self, cls, flag);
exit:
return return_value;
@@ -387,4 +368,4 @@ exit:
#ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */
-/*[clinic end generated code: output=14e37efc4ec10be2 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=612b9d6a17a679a7 input=a9049054013a1b77]*/