[issue35874] Clarify that the (...) convertor to PyArg_ParseTuple... accepts any sequence.

2019-02-14 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Passing non-tuple can lead to reference counting error. See issue6083. I think 
that accepting a non-tuple should be deprecated, and finally disallowed.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35874] Clarify that the (...) convertor to PyArg_ParseTuple... accepts any sequence.

2019-02-01 Thread Antony Lee

New submission from Antony Lee :

The documentation for the accepted types for each format unit in 
PyArg_ParseTuple (and its variants) is usually quite detailed; compare for 
example

y* (bytes-like object) [Py_buffer]
This variant on s* doesn’t accept Unicode objects, only bytes-like objects. 
This is the recommended way to accept binary data.

and

S (bytes) [PyBytesObject *]
Requires that the Python object is a bytes object, without attempting any 
conversion. Raises TypeError if the object is not a bytes object. The C 
variable may also be declared as PyObject*.

There, the type in parenthesis (which is explained as "the entry in (round) 
parentheses is the Python object type that matches the format unit") 
differentiates between "bytes-like object" and "bytes".

However, the documentation for "(...)" is a bit more confusing:

(items) (tuple) [matching-items]
The object must be a Python sequence whose length is the number of format 
units in items. The C arguments must correspond to the individual format units 
in items. Format units for sequences may be nested.

The type in parenthesis is "tuple" (exactly), but the paragraph says 
"sequence".  The actual behavior appears indeed to be that any sequence (e.g., 
list, numpy array) is accepted, so I'd suggest changing the type in the 
parenthesis to "sequence".

--
assignee: docs@python
components: Documentation
messages: 334660
nosy: Antony.Lee, docs@python
priority: normal
severity: normal
status: open
title: Clarify that the (...) convertor to PyArg_ParseTuple... accepts any 
sequence.

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com