New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug skipping optional keyword arguments of type "w#" #40513
Comments
When using PyArg_ParseTupleAndKeywords(), if you use static PyObject *
dummy_func(PyObject *self, PyObject *args, PyObject *kwds)
{
char *string;
char *buf = NULL;
int bufsize = 0;
unsigned short ushort = 5;
static char *kwlist[] = { "string", "buffer",
"ushort", NULL };
"s|w#H", kwlist,
bufsize, ushort);
} You can call this function successfully as follows: # don't specify buffer or ushort
dummy_func("text") Or like this: # specify buffer
buf = array.array('c', [' ' for x in range(0, 1023)])
dummy_func("text", buffer=buf) Or like this: # specify buffer and ushort
buf = array.array('c', [' ' for x in range(0, 1023)])
dummy_func("text", buffer=buf, ushort=10) However, the following does NOT work: # specify ushort without first specifying buffer
dummy_func("text", ushort=10) It fails with the following error: Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: argument 2 impossible<bad format char> This is because the skipitem() function in Note that skipitem() is also missing code for many u, u# (see patch bpo-853890) It might be a good idea to refactor the code so that |
Logged In: YES Whoops! You'll need to change "hostname" to "string" in |
Logged In: YES I applied your patch and ran the Python test suite, finding |
Logged In: YES Closing; subsumed by bpo-1212928. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: