Skip to content
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

PyArg_ParseTupleAndKeywords and fields take (non-const) char *keywords[] #28

Open
iritkatriel opened this issue May 14, 2023 · 3 comments
Labels
theme: implementation flaws problems with the implementation of specific APIs

Comments

@iritkatriel
Copy link
Member

See python/cpython#65210.

@iritkatriel iritkatriel added the theme: implementation flaws problems with the implementation of specific APIs label May 14, 2023
@gvanrossum
Copy link

The best explanation I've found is this message from Martin von Loewis. There are a few messages after that where people are trying to come up with a solution, unfruitfully; after that the discussion degenerates into a flame war about C++.

I'm actually still not sure what we could do differently in the 4.0 API -- make it const * const * keywords?

@serhiy-storchaka
Copy link

It explains why char ** cannot be implicitly converted to const char **, but not why it cannot be implicitly converted to const char * const *. And in C++ (which in general is more strictly types than C) such implicit conversion is supported. Why it does not work in C? The answer is because. The C rules are simpler than the C++ rules, so they did not bother to add special rules for such implicitly conversion, even if this causes some inconvenience in practice. I only hope that they will change this in future versions.

I think that we can fix this in C++ in compatible way, but for C we can only provide a lever to chose between const char * const * and char * const * (the latter is compatible with char **). It could also make transition to future incompatible C API (if we decide to break it) simpler.

@serhiy-storchaka
Copy link

See python/cpython#105958 as example.

@iritkatriel iritkatriel added the v label Jul 21, 2023
@iritkatriel iritkatriel removed the v label Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: implementation flaws problems with the implementation of specific APIs
Projects
None yet
Development

No branches or pull requests

3 participants