GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-65210: Add const qualifiers in PyArg_VaParseTupleAndKeywords() by serhiy-storchaka · Pull Request #105958 · python/cpython Conversation
|
|
|
||
| The *keywords* parameter declaration is :c:expr:`char * const *` in C and | ||
| :c:expr:`const char * const *` in C++. | ||
| This can be overridden by defining the macro :c:macro:`PY_CXX_CONST` |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please document this new macro somewhere with .. c:macro:: PY_CXX_CONST.
That will fix this warning and the one in 3.13.rst and the CI.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I do not know how to document it better than I did. I will appreciate your suggestions. For now I just removed the role.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@CAM-Gerlach Any suggestions?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@serhiy-storchaka To properly document a public entity (macro, function, class, method, etc), you can use the the appropriate directive—in this case, .. c:macro:: as @hugovk mentioned. This could be something like (placed, perhaps, at the top or bottom of the API Functions subsection):
.. macro:: PY_CXX_CONST The value to be inserted, if any, before :c:expr:`char * const *` in the *keywords* parameter declaration of :c:func:`PyArg_ParseTupleAndKeywords` and :c:func:`PyArg_VaParseTupleAndKeywords`. Default empty for C and ``const`` for C++ (:c:expr:`const char * const *`). To override, define it to the desired value before including :file:`Python.h`. .. versionadded:: 3.13
You can then simplify this note accordingly, per my other suggestion (in a separate comment).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| :c:expr:`char * const *` in C++ and :c:expr:`char * const *` in C | ||
| without explicit type cast. | ||
| This can be overridden by defining the macro :c:macro:`PY_CXX_CONST` | ||
| This can be overridden by defining the macro ``PY_CXX_CONST`` |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can we use this?
| This can be overridden by defining the macro ``PY_CXX_CONST`` | |
| This can be overridden by defining the macro :c:macro:`!PY_CXX_CONST` |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yes, both :c:macro:`!PY_CXX_CONST` and ``PY_CXX_CONST`` would work.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
To note, while they both silence the warning, they have different semantics in the source and rendering in the output.
However, with the changes suggested above, it is a moot point as you can link this and also simplify this What's New entry by referring readers to the macro description, which explains this (instead of duplicating the explanation here).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| The *keywords* parameter declaration is :c:expr:`char * const *` in C and | ||
| :c:expr:`const char * const *` in C++. | ||
| This can be overridden by defining the macro :c:macro:`PY_CXX_CONST` |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@serhiy-storchaka To properly document a public entity (macro, function, class, method, etc), you can use the the appropriate directive—in this case, .. c:macro:: as @hugovk mentioned. This could be something like (placed, perhaps, at the top or bottom of the API Functions subsection):
.. macro:: PY_CXX_CONST The value to be inserted, if any, before :c:expr:`char * const *` in the *keywords* parameter declaration of :c:func:`PyArg_ParseTupleAndKeywords` and :c:func:`PyArg_VaParseTupleAndKeywords`. Default empty for C and ``const`` for C++ (:c:expr:`const char * const *`). To override, define it to the desired value before including :file:`Python.h`. .. versionadded:: 3.13
You can then simplify this note accordingly, per my other suggestion (in a separate comment).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| This can be overridden by defining the macro :c:macro:`PY_CXX_CONST` | ||
| before including :file:`Python.h` as ``const`` for the latter and as | ||
| empty value for the former. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| This can be overridden by defining the macro :c:macro:`PY_CXX_CONST` | |
| before including :file:`Python.h` as ``const`` for the latter and as | |
| empty value for the former. | |
| This can be overridden with the :c:macro:`PY_CXX_CONST` macro. |
Refer to the newly-added macro's documentation instead of needing to repeat these details here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| :c:expr:`char * const *` in C++ and :c:expr:`char * const *` in C | ||
| without explicit type cast. | ||
| This can be overridden by defining the macro :c:macro:`PY_CXX_CONST` | ||
| This can be overridden by defining the macro ``PY_CXX_CONST`` |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
To note, while they both silence the warning, they have different semantics in the source and rendering in the output.
However, with the changes suggested above, it is a moot point as you can link this and also simplify this What's New entry by referring readers to the macro description, which explains this (instead of duplicating the explanation here).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| This can be overridden by defining the macro ``PY_CXX_CONST`` | ||
| before including :file:`Python.h` as ``const`` for the latter and as | ||
| empty value for the former. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| This can be overridden by defining the macro ``PY_CXX_CONST`` | |
| before including :file:`Python.h` as ``const`` for the latter and as | |
| empty value for the former. | |
| This can be overridden with the :c:macro:`PY_CXX_CONST` macro. |
Now that this is documented, simply refer interested readers here directly instead of duplicating the whole explanation.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * The *keywords* parameter of :c:func:`PyArg_ParseTupleAndKeywords` and | ||
| :c:func:`PyArg_VaParseTupleAndKeywords` has now type :c:expr:`char * const *` | ||
| in C and :c:expr:`const char * const *` in C++, instead of :c:expr:`char **`. | ||
| It makes these functions compatible with argument of type |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| It makes these functions compatible with argument of type | |
| It makes these functions compatible with arguments of type |
Fix grammar error
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| It makes these functions compatible with argument of type | ||
| :c:expr:`const char * const *`, :c:expr:`const char **` or | ||
| :c:expr:`char * const *` in C++ and :c:expr:`char * const *` in C | ||
| without explicit type cast. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| without explicit type cast. | |
| without an explicit type cast. |
Fix grammar error
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Standard reminder: You can directly apply all the suggestions you want in one go by going to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: C.A.M. Gerlach <[email protected]>
4ff9e8f to
0e4dc59
Compare
|
@CAM-Gerlach Thank you, I applied all your suggestions. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…() (pythonGH-105958) Change the declaration of the keywords parameter in functions PyArg_ParseTupleAndKeywords() and PyArg_VaParseTupleAndKeywords() from `char **` to `char * const *` in C and `const char * const *` in C++. It makes these functions compatible with argument of type `const char * const *`, `const char **` or `char * const *` in C++ and `char * const *` in C without explicit type cast. Co-authored-by: C.A.M. Gerlach <[email protected]>
…() (pythonGH-105958) Change the declaration of the keywords parameter in functions PyArg_ParseTupleAndKeywords() and PyArg_VaParseTupleAndKeywords() from `char **` to `char * const *` in C and `const char * const *` in C++. It makes these functions compatible with argument of type `const char * const *`, `const char **` or `char * const *` in C++ and `char * const *` in C without explicit type cast. Co-authored-by: C.A.M. Gerlach <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.