diff options
author | Victor Stinner <vstinner@python.org> | 2023-11-01 15:34:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-01 15:34:42 (GMT) |
commit | d9b606b3d04fc56fb0bcc479d7d6c14562edb5e2 (patch) | |
tree | 14d10605507380e411d5f62e5bab28f74091129d /Modules/clinic/_hashopenssl.c.h | |
parent | 97b3cd38d105fd891ba46dd27d08f03d1c6dd348 (diff) | |
download | cpython-d9b606b3d04fc56fb0bcc479d7d6c14562edb5e2.zip cpython-d9b606b3d04fc56fb0bcc479d7d6c14562edb5e2.tar.gz cpython-d9b606b3d04fc56fb0bcc479d7d6c14562edb5e2.tar.bz2 |
gh-111089: Use PyUnicode_AsUTF8() in Argument Clinic (#111585)
Replace PyUnicode_AsUTF8AndSize() with PyUnicode_AsUTF8() to remove
the explicit check for embedded null characters.
The change avoids to have to include explicitly <string.h> to get the
strlen() function when using a recent version of the limited C API.
Diffstat (limited to 'Modules/clinic/_hashopenssl.c.h')
-rw-r--r-- | Modules/clinic/_hashopenssl.c.h | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/Modules/clinic/_hashopenssl.c.h b/Modules/clinic/_hashopenssl.c.h index 58650df..e360e98 100644 --- a/Modules/clinic/_hashopenssl.c.h +++ b/Modules/clinic/_hashopenssl.c.h @@ -1278,15 +1278,10 @@ pbkdf2_hmac(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject _PyArg_BadArgument("pbkdf2_hmac", "argument 'hash_name'", "str", args[0]); goto exit; } - Py_ssize_t hash_name_length; - hash_name = PyUnicode_AsUTF8AndSize(args[0], &hash_name_length); + hash_name = PyUnicode_AsUTF8(args[0]); if (hash_name == NULL) { goto exit; } - if (strlen(hash_name) != (size_t)hash_name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (PyObject_GetBuffer(args[1], &password, PyBUF_SIMPLE) != 0) { goto exit; } @@ -1824,4 +1819,4 @@ exit: #ifndef _HASHLIB_SCRYPT_METHODDEF #define _HASHLIB_SCRYPT_METHODDEF #endif /* !defined(_HASHLIB_SCRYPT_METHODDEF) */ -/*[clinic end generated code: output=b7eddeb3d6ccdeec input=a9049054013a1b77]*/ +/*[clinic end generated code: output=bc372898eaa3e000 input=a9049054013a1b77]*/ |