[Python-Dev] Inconsistent Use of Buffer Interface instringobject.c

Fredrik Lundh fredrik at pythonware.com
Mon Oct 24 20:19:05 CEST 2005


Guido van Rossum wrote:

> A concern I'd have with fixing this is that Unicode objects also
> support the buffer API. In any situation where either str or unicode
> is accepted I'd be reluctant to guess whether a buffer object was
> meant to be str-like or Unicode-like. I think this covers all the
> cases you mention here.

iirc, SRE solves that by comparing the length of the sequence with the
number of bytes in the buffer.  if length == bytes, it's an 8-bit string; if
length*sizeof(Py_Unicode) == bytes, it's a Unicode string.

</F>





More information about the Python-Dev mailing list