[issue8839] PyArg_ParseTuple(): remove "t# format

Marc-Andre Lemburg report at bugs.python.org
Fri May 28 10:14:57 CEST 2010


Marc-Andre Lemburg <mal at egenix.com> added the comment:

STINNER Victor wrote:
> 
> New submission from STINNER Victor <victor.stinner at haypocalc.com>:
> 
> "t#" format was introduced by r11803 (11 years ago): "Implement new format character 't#'. This is like s#, accepting an object that implements the buffer interface, but requires a buffer that contains 8-bit character data."
> 
> Python3 now has a strict separation between byte string (bytes and bytearray types) and unicode string (str), and has PyBuffer and PyCapsule APIs. "t#" format can be replaced by "y#" or "y*".
>
> Extract of getarg.c:
> 
>       /*TEO: This can be eliminated --- here only for backward
>         compatibility */
>     case 't': { /* 8-bit character buffer, read-only access */
> 
> In Python, the last function using "t#" is _codecs.charbuffer_encode() and I proposed to remove this function in #8838. We can also patch this function.
> 
> I don't know if third party modules use this format or not. I don't know if it can be just removed or if it should raise a deprecation warning (but who will notice such warning since there are disabled by default?).

Since Python3 completely removed the getcharbuffer interface
to which the "t#" interfaces in Python2, "t#" does indeed no
longer serve any special purpose.

It's probably wise to just map "t#" to "y#" in order to ease
porting extensions from 2.x to 3.x.

----------
nosy: +lemburg

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8839>
_______________________________________


More information about the Python-bugs-list mailing list