summaryrefslogtreecommitdiffstats
path: root/Modules/clinic/_cryptmodule.c.h
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-01-11 14:01:14 (GMT)
committerGitHub <noreply@github.com>2019-01-11 14:01:14 (GMT)
commit4fa9591025b6a098f3d6402e5413ee6740ede6c5 (patch)
treea81280fdd40c6a5b8c00613b0a8903624499afc5 /Modules/clinic/_cryptmodule.c.h
parent5485085b324a45307c1ff4ec7d85b5998d7d5e0d (diff)
downloadcpython-4fa9591025b6a098f3d6402e5413ee6740ede6c5.zip
cpython-4fa9591025b6a098f3d6402e5413ee6740ede6c5.tar.gz
cpython-4fa9591025b6a098f3d6402e5413ee6740ede6c5.tar.bz2
bpo-35582: Argument Clinic: inline parsing code for positional parameters. (GH-11313)
Diffstat (limited to 'Modules/clinic/_cryptmodule.c.h')
-rw-r--r--Modules/clinic/_cryptmodule.c.h31
1 files changed, 28 insertions, 3 deletions
diff --git a/Modules/clinic/_cryptmodule.c.h b/Modules/clinic/_cryptmodule.c.h
index baa31e2..2fcb0c1 100644
--- a/Modules/clinic/_cryptmodule.c.h
+++ b/Modules/clinic/_cryptmodule.c.h
@@ -26,8 +26,33 @@ crypt_crypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
const char *word;
const char *salt;
- if (!_PyArg_ParseStack(args, nargs, "ss:crypt",
- &word, &salt)) {
+ if (!_PyArg_CheckPositional("crypt", nargs, 2, 2)) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("crypt", 1, "str", args[0]);
+ goto exit;
+ }
+ Py_ssize_t word_length;
+ word = PyUnicode_AsUTF8AndSize(args[0], &word_length);
+ if (word == NULL) {
+ goto exit;
+ }
+ if (strlen(word) != (size_t)word_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[1])) {
+ _PyArg_BadArgument("crypt", 2, "str", args[1]);
+ goto exit;
+ }
+ Py_ssize_t salt_length;
+ salt = PyUnicode_AsUTF8AndSize(args[1], &salt_length);
+ if (salt == NULL) {
+ goto exit;
+ }
+ if (strlen(salt) != (size_t)salt_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = crypt_crypt_impl(module, word, salt);
@@ -35,4 +60,4 @@ crypt_crypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
exit:
return return_value;
}
-/*[clinic end generated code: output=79001dbfdd623ff9 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=3f75d4d4be4dddbb input=a9049054013a1b77]*/