summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-01-24 14:05:30 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2017-01-24 14:05:30 (GMT)
commitc3858bd7c6e6ef37978b8483a9fe594f29b4b2de (patch)
tree0725e4f21874d89776a14be75c9104e64617413f /Include
parent90f6332382d616ce5a3329c1176ffa1cff27ea7e (diff)
downloadcpython-c3858bd7c6e6ef37978b8483a9fe594f29b4b2de.zip
cpython-c3858bd7c6e6ef37978b8483a9fe594f29b4b2de.tar.gz
cpython-c3858bd7c6e6ef37978b8483a9fe594f29b4b2de.tar.bz2
Issue #29360: _PyStack_AsDict() doesn't check kwnames
Remove two assertions which can fail on legit code. Keyword arguments are checked later with better tests and raise a regular (TypeError) exception.
Diffstat (limited to 'Include')
-rw-r--r--Include/abstract.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/Include/abstract.h b/Include/abstract.h
index 6647be7..231e209 100644
--- a/Include/abstract.h
+++ b/Include/abstract.h
@@ -166,13 +166,16 @@ PyAPI_FUNC(PyObject*) _PyStack_AsTupleSlice(
Py_ssize_t start,
Py_ssize_t end);
-/* Convert keyword arguments from the (stack, kwnames) format to a Python
- dictionary.
+/* Convert keyword arguments from the FASTCALL (stack: C array, kwnames: tuple)
+ format to a Python dictionary ("kwargs" dict).
- kwnames must only contains str strings, no subclass, and all keys must be
- unique. kwnames is not checked, usually these checks are done before or
- later calling _PyStack_AsDict(). For example, _PyArg_ParseStackAndKeywords() raises an
- error if a key is not a string. */
+ The type of kwnames keys is not checked. The final function getting
+ arguments is reponsible to check if all keys are strings, for example using
+ PyArg_ParseTupleAndKeywords() or PyArg_ValidateKeywordArguments().
+
+ Duplicate keys are merged using the last value. If duplicate keys must raise
+ an exception, the caller is responsible to implement an explicit keys on
+ kwnames. */
PyAPI_FUNC(PyObject *) _PyStack_AsDict(
PyObject **values,
PyObject *kwnames);