diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-12-25 11:23:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-25 11:23:47 (GMT) |
commit | 32d96a2b5bc3136d45a66adbdb45fac351b520ce (patch) | |
tree | acf51c9945f764ab103597c9cba376f154aa600d /Modules/clinic/unicodedata.c.h | |
parent | 65ce60aef150776f884715b4315a10a0d6ae769e (diff) | |
download | cpython-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/unicodedata.c.h')
-rw-r--r-- | Modules/clinic/unicodedata.c.h | 68 |
1 files changed, 61 insertions, 7 deletions
diff --git a/Modules/clinic/unicodedata.c.h b/Modules/clinic/unicodedata.c.h index 4799fb4..9e8d261 100644 --- a/Modules/clinic/unicodedata.c.h +++ b/Modules/clinic/unicodedata.c.h @@ -121,9 +121,18 @@ unicodedata_UCD_category(PyObject *self, PyObject *arg) PyObject *return_value = NULL; int chr; - if (!PyArg_Parse(arg, "C:category", &chr)) { + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("category", "a unicode character", arg); goto exit; } + if (PyUnicode_READY(arg)) { + goto exit; + } + if (PyUnicode_GET_LENGTH(arg) != 1) { + _PyArg_BadArgument("category", "a unicode character", arg); + goto exit; + } + chr = PyUnicode_READ_CHAR(arg, 0); return_value = unicodedata_UCD_category_impl(self, chr); exit: @@ -150,9 +159,18 @@ unicodedata_UCD_bidirectional(PyObject *self, PyObject *arg) PyObject *return_value = NULL; int chr; - if (!PyArg_Parse(arg, "C:bidirectional", &chr)) { + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("bidirectional", "a unicode character", arg); + goto exit; + } + if (PyUnicode_READY(arg)) { goto exit; } + if (PyUnicode_GET_LENGTH(arg) != 1) { + _PyArg_BadArgument("bidirectional", "a unicode character", arg); + goto exit; + } + chr = PyUnicode_READ_CHAR(arg, 0); return_value = unicodedata_UCD_bidirectional_impl(self, chr); exit: @@ -180,9 +198,18 @@ unicodedata_UCD_combining(PyObject *self, PyObject *arg) int chr; int _return_value; - if (!PyArg_Parse(arg, "C:combining", &chr)) { + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("combining", "a unicode character", arg); + goto exit; + } + if (PyUnicode_READY(arg)) { + goto exit; + } + if (PyUnicode_GET_LENGTH(arg) != 1) { + _PyArg_BadArgument("combining", "a unicode character", arg); goto exit; } + chr = PyUnicode_READ_CHAR(arg, 0); _return_value = unicodedata_UCD_combining_impl(self, chr); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -215,9 +242,18 @@ unicodedata_UCD_mirrored(PyObject *self, PyObject *arg) int chr; int _return_value; - if (!PyArg_Parse(arg, "C:mirrored", &chr)) { + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("mirrored", "a unicode character", arg); goto exit; } + if (PyUnicode_READY(arg)) { + goto exit; + } + if (PyUnicode_GET_LENGTH(arg) != 1) { + _PyArg_BadArgument("mirrored", "a unicode character", arg); + goto exit; + } + chr = PyUnicode_READ_CHAR(arg, 0); _return_value = unicodedata_UCD_mirrored_impl(self, chr); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -246,9 +282,18 @@ unicodedata_UCD_east_asian_width(PyObject *self, PyObject *arg) PyObject *return_value = NULL; int chr; - if (!PyArg_Parse(arg, "C:east_asian_width", &chr)) { + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("east_asian_width", "a unicode character", arg); + goto exit; + } + if (PyUnicode_READY(arg)) { goto exit; } + if (PyUnicode_GET_LENGTH(arg) != 1) { + _PyArg_BadArgument("east_asian_width", "a unicode character", arg); + goto exit; + } + chr = PyUnicode_READ_CHAR(arg, 0); return_value = unicodedata_UCD_east_asian_width_impl(self, chr); exit: @@ -275,9 +320,18 @@ unicodedata_UCD_decomposition(PyObject *self, PyObject *arg) PyObject *return_value = NULL; int chr; - if (!PyArg_Parse(arg, "C:decomposition", &chr)) { + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("decomposition", "a unicode character", arg); + goto exit; + } + if (PyUnicode_READY(arg)) { + goto exit; + } + if (PyUnicode_GET_LENGTH(arg) != 1) { + _PyArg_BadArgument("decomposition", "a unicode character", arg); goto exit; } + chr = PyUnicode_READ_CHAR(arg, 0); return_value = unicodedata_UCD_decomposition_impl(self, chr); exit: @@ -411,4 +465,4 @@ unicodedata_UCD_lookup(PyObject *self, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=67f474927be668bf input=a9049054013a1b77]*/ +/*[clinic end generated code: output=709241b99d010896 input=a9049054013a1b77]*/ |