[Python-3000] need help fixing broken tests in py3k-pep3137 branch
Guido van Rossum
guido at python.org
Sat Nov 3 16:25:48 CET 2007
To clarify: while a bytes object *could* be interpreted as either a
sequence of ints or a memory array, the *intent* is that the memory
array interpretation prevails. An Christian correctly fixed it to do
so. The external docs and docstrings of many, many modules are
currently incorrectly referring to strings; I hope I can get some more
volunteers to help clean up all that. Also, almost everywhere that
checks for bytes should be recoded to accept any buffer-API-supporting
object. The docs should reflect that. We could use a better term than
buffer-API-supporting object though!
On 11/3/07, Paul Moore <p.f.moore at gmail.com> wrote:
> On 03/11/2007, Christian Heimes <lists at cheimes.de> wrote:
> > You are partly right. The documentation needs an update. It should say
> > "which mist be a list, string, byte sequence or iterable ...".
> Actually, "string" is a holdover from the Python 2.x behaviour you
> point out below. In 3.x, strings are not special:
> >>> array.array('H',"1234")
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: an integer is required
> Also, based on Nick Coghlan's comment, this should be an object
> implementing the buffer protocol rather than a byte sequence. This
> isn't the case in Python 2.x, but seems to be in Python 3.0.
> So, the wording should probably be: "which must be a list, object
> supporting the buffer interface or iterable ...".
> > In Python 2.x the array module handles strings in the same way:
> > Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32)
> > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> import array
> > >>> array.array('H', "1234")
> > array('H', [12849, 13363])
> > Bytes are the successor of Python 2.x's byte strings (str). They are
> > even using the same C type PyString. My patch has only restored the old
> > behavior of PyString.
> OK, thanks for the clarification (again!).
> Python-3000 mailing list
> Python-3000 at python.org
> Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000