8000 gh-65210: Add const qualifiers in PyArg_VaParseTupleAndKeywords() by serhiy-storchaka · Pull Request #105958 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-65210: Add const qualifiers in PyArg_VaParseTupleAndKeywords() #105958

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

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into PyArg_ParseTupleAndKeywords-const
  • Loading branch information
serhiy-storchaka committed Dec 1, 2023
commit 910c5d2229c128f95e71c69bd205818d33d13991
2 changes: 2 additions & 0 deletions Doc/c-api/arg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ API Functions
.. versionchanged:: 3.13
The *keywords* parameter has now type :c:expr:`char * const *` in C and
:c:expr:`const char * const *` in C++, instead of :c:expr:`char **`.
Added support for non-ASCII keyword parameter names.



.. c:function:: int PyArg_VaParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char * const *keywords, va_list vargs)
Expand Down
55 changes: 12 additions & 43 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,18 @@ New Features
APIs accepting the format codes always use ``Py_ssize_t`` for ``#`` formats.
(Contributed by Inada Naoki in :gh:`104922`.)

* 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
Copy link
Member
10000

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It makes these functions compatible with argument of type
It makes these functions compatible with arguments of type

Fix grammar error

: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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
without explicit type cast.
without an explicit type cast.

Fix grammar error

This can be overridden by defining the macro ``PY_CXX_CONST``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use this?

Suggested change
This can be overridden by defining the macro ``PY_CXX_CONST``
This can be overridden by defining the macro :c:macro:`!PY_CXX_CONST`

Copy link
Member Author

Choose a reason for 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.

Copy link
Member

Choose a reason for 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).

before including :file:`Python.h` as ``const`` for the latter and as
empty value for the former.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

(Contributed by Serhiy Storchaka in :gh:`65210`.)

* Add :c:func:`PyImport_AddModuleRef`: similar to
:c:func:`PyImport_AddModule`, but return a :term:`strong reference` instead
of a :term:`borrowed reference`.
Expand Down Expand Up @@ -1289,49 +1301,6 @@ Porting to Python 3.13
platforms, the ``HAVE_STDDEF_H`` macro is only defined on Windows.
(Contributed by Victor Stinner in :gh:`108765`.)

Build Changes
=============

* Autoconf 2.71 and aclocal 1.16.4 is now required to regenerate
:file:`!configure`.
(Contributed by Christian Heimes in :gh:`89886`.)

* SQLite 3.15.2 or newer is required to build the :mod:`sqlite3` extension module.
(Contributed by Erlend Aasland in :gh:`105875`.)


C API Changes
=============

New Features
------------

* You no longer have to define the ``PY_SSIZE_T_CLEAN`` macro before including
:file:`Python.h` when using ``#`` formats in
:ref:`format codes <arg-parsing-string-and-buffers>`.
APIs accepting the format codes always use ``Py_ssize_t`` for ``#`` formats.
(Contributed by Inada Naoki in :gh:`104922`.)

* 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
: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.
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.
(Contributed by Serhiy Storchaka in :gh:`65210`.)

* Add :c:func:`PyImport_AddModuleRef`: similar to
:c:func:`PyImport_AddModule`, but return a :term:`strong reference` instead
of a :term:`borrowed reference`.
(Contributed by Victor Stinner in :gh:`105922`.)


Porting to Python 3.13
----------------------

Deprecated
----------
Expand Down
4 changes: 4 additions & 0 deletions Include/pyport.h
Original file line number Diff line number Diff line change
Expand Up @@ -594,4 +594,8 @@ extern "C" {
# endif
#endif

#if defined(__sgi) && !defined(_SGI_MP_SOURCE)
# define _SGI_MP_SOURCE
#endif

#endif /* Py_PYPORT_H */
You are viewing a condensed version of this merge commit. You can view the full changes here.
0