10000 gh-50333: Deprecate support of non-tuple sequences in PyArg_ParseTuple() by serhiy-storchaka · Pull Request #128374 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-50333: Deprecate support of non-tuple sequences in PyArg_ParseTuple() #128374

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
Merged
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 2, 2025
commit 9878b37001a944fd2bd16e70268432c29c8cc972
10 changes: 5 additions & 5 deletions Doc/c-api/arg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -344,17 +344,17 @@ Other objects
in *items*. The C arguments must correspond to the individual format units in
*items*. Format units for sequences may be nested.

If *items* contains format units which store
If *items* contains format units which store a
:ref:`borrowed buffer <c-arg-borrowed-buffer>` or
:term:`reference <borrowed reference>`
a :term:`borrowed reference`
(``y``, ``y#``, ``s``, ``s#``, ``z``, ``z#``, ``S``, ``Y``, ``U``,
``O`` or ``O!``) the object must be a Python tuple.
``O`` or ``O!``), the object must be a Python tuple.
The *converter* for the ``O&`` format unit in *items* must not store
borrowed buffer or reference.
a borrowed buffer or reference.

.. deprecated:: next
Non-tuple sequences are deprecated if *items* contains format units
which store borrowed buffer or reference.
which store a borrowed buffer or reference.

It is possible to pass "long" integers (integers whose value exceeds the
platform's :c:macro:`LONG_MAX`) however no proper range checking is done --- the
Expand Down
4 changes: 2 additions & 2 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1230,8 +1230,8 @@ Deprecated
* Non-tuple sequences are deprecated as argument for the ``(items)``
format unit in :c:func:`PyArg_ParseTuple` and other
:ref:`argument parsing <arg-parsing>` functions if *items* contains
format units which store :ref:`borrowed buffer <c-arg-borrowed-buffer>` or
:term:`reference <borrowed reference>`.
format units which store a :ref:`borrowed buffer <c-arg-borrowed-buffer>`
or a :term:`borrowed reference`.
(Contributed by Serhiy Storchaka in :gh:`50333`.)

* The previously undocumented function :c:func:`PySequence_In` is :term:`soft deprecated`.
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_capi/test_getargs.py
A24B
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ def test_tuple(self):
ret = getargs_tuple(1, (2, 3))
self.assertEqual(ret, (1,2,3))

# make sure invalid tuple arguments are handled correctly
# make sure invalid sequence arguments are handled correctly
class TestSeq:
def __len__(self):
return 2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Non-tuple sequences are deprecated as argument for the ``(items)`` format
unit in :c:func:`PyArg_ParseTuple` and other :ref:`argument parsing
<arg-parsing>` functions if *items* contains format units which store
:ref:`borrowed buffer <c-arg-borrowed-buffer>` or :term:`reference <borrowed
reference>`.
a :ref:`borrowed buffer <c-arg-borrowed-buffer>` or a :term:`borrowed
reference`.
Loading
0