[New-bugs-announce] [issue3156] bytes type has inconsistent methods (append, insert)
A.M. Kuchling
report at bugs.python.org
Sat Jun 21 01:35:00 CEST 2008
New submission from A.M. Kuchling <lists at amk.ca>:
bytearray's methods aren't consistent in what they accept.
append() takes either an int or a character:
>>> b = bytearray('abc')
>>> b.append(76) ; b
bytearray(b'abcL')
>>> b.append('M') ; b
bytearray(b'abcLM')
.insert() accepts only integers:
>>> b.insert(0, 97) ; b
bytearray(b'aabcLM')
>>> b.insert(0, 'a') ; b
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: an integer is required
Both PEP 358 and the docstring for .append() only document 'int' as a
legal input, so I suspect append() is wrong here.
----------
messages: 68487
nosy: akuchling
severity: normal
status: open
title: bytes type has inconsistent methods (append, insert)
type: behavior
versions: Python 2.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3156>
_______________________________________
More information about the New-bugs-announce
mailing list