summaryrefslogtreecommitdiffstats
path: root/Python/clinic/Python-tokenize.c.h
diff options
context:
space:
mode:
Diffstat (limited to 'Python/clinic/Python-tokenize.c.h')
-rw-r--r--Python/clinic/Python-tokenize.c.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/Python/clinic/Python-tokenize.c.h b/Python/clinic/Python-tokenize.c.h
index 7417020..730fa8e 100644
--- a/Python/clinic/Python-tokenize.c.h
+++ b/Python/clinic/Python-tokenize.c.h
@@ -65,14 +65,19 @@ tokenizeriter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
_PyArg_BadArgument("tokenizeriter", "argument 'encoding'", "str", fastargs[2]);
goto exit;
}
- encoding = PyUnicode_AsUTF8(fastargs[2]);
+ Py_ssize_t encoding_length;
+ encoding = PyUnicode_AsUTF8AndSize(fastargs[2], &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_kwonly:
return_value = tokenizeriter_new_impl(type, readline, extra_tokens, encoding);
exit:
return return_value;
}
-/*[clinic end generated code: output=92cb8176149f0924 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=dcd6ec48f06a092e input=a9049054013a1b77]*/