[New-bugs-announce] [issue34235] PyArg_ParseTupleAndKeywords: support required keyword arguments

Serhiy Storchaka report at bugs.python.org
Thu Jul 26 09:04:17 EDT 2018


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

In Python the function can have 4 kinds of parameters:

    def f(a, b=1, *, c, d=2):

1. a is a required positional-or-keyword parameter.
2. b is an optional positional-or-keyword parameter.
3. c is a required keyword-only parameter.
4. d is an optional keyword-only parameter.

But PyArg_ParseTupleAndKeywords() supports only 3 of them. Keyword-only parameters can only be optional.

    PyArg_ParseTupleAndKeywords(args, kwds, "O|O$O", kwlist, &a, &b, &d)

This makes impossible using PyArg_ParseTupleAndKeywords() for haslib.scrypt(). Currently it parses all keyword-only arguments as optional, and checks that they are specified specially, but this does not allow to use the full power of the PyArg_Parse* API.

----------
assignee: serhiy.storchaka
components: Interpreter Core
messages: 322419
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: PyArg_ParseTupleAndKeywords: support required keyword arguments
type: enhancement
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34235>
_______________________________________


More information about the New-bugs-announce mailing list