summaryrefslogtreecommitdiffstats
path: root/Modules/clinic/pyexpat.c.h
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-12-25 11:23:47 (GMT)
committerGitHub <noreply@github.com>2018-12-25 11:23:47 (GMT)
commit32d96a2b5bc3136d45a66adbdb45fac351b520ce (patch)
treeacf51c9945f764ab103597c9cba376f154aa600d /Modules/clinic/pyexpat.c.h
parent65ce60aef150776f884715b4315a10a0d6ae769e (diff)
downloadcpython-32d96a2b5bc3136d45a66adbdb45fac351b520ce.zip
cpython-32d96a2b5bc3136d45a66adbdb45fac351b520ce.tar.gz
cpython-32d96a2b5bc3136d45a66adbdb45fac351b520ce.tar.bz2
bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689)
Diffstat (limited to 'Modules/clinic/pyexpat.c.h')
-rw-r--r--Modules/clinic/pyexpat.c.h30
1 files changed, 26 insertions, 4 deletions
diff --git a/Modules/clinic/pyexpat.c.h b/Modules/clinic/pyexpat.c.h
index 5e6db44..1545485 100644
--- a/Modules/clinic/pyexpat.c.h
+++ b/Modules/clinic/pyexpat.c.h
@@ -61,7 +61,17 @@ pyexpat_xmlparser_SetBase(xmlparseobject *self, PyObject *arg)
PyObject *return_value = NULL;
const char *base;
- if (!PyArg_Parse(arg, "s:SetBase", &base)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("SetBase", "str", arg);
+ goto exit;
+ }
+ Py_ssize_t base_length;
+ base = PyUnicode_AsUTF8AndSize(arg, &base_length);
+ if (base == NULL) {
+ goto exit;
+ }
+ if (strlen(base) != (size_t)base_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = pyexpat_xmlparser_SetBase_impl(self, base);
@@ -163,7 +173,13 @@ pyexpat_xmlparser_SetParamEntityParsing(xmlparseobject *self, PyObject *arg)
PyObject *return_value = NULL;
int flag;
- if (!PyArg_Parse(arg, "i:SetParamEntityParsing", &flag)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ flag = _PyLong_AsInt(arg);
+ if (flag == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = pyexpat_xmlparser_SetParamEntityParsing_impl(self, flag);
@@ -260,7 +276,13 @@ pyexpat_ErrorString(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
long code;
- if (!PyArg_Parse(arg, "l:ErrorString", &code)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ code = PyLong_AsLong(arg);
+ if (code == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = pyexpat_ErrorString_impl(module, code);
@@ -272,4 +294,4 @@ exit:
#ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */
-/*[clinic end generated code: output=c390207761c679d3 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d3750256eb0da1cb input=a9049054013a1b77]*/