This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2008年06月20日 23:34 by akuchling, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue3156.patch | brunogola, 2008年06月21日 20:26 | patch for issue 3156 | ||
| Messages (3) | |||
|---|---|---|---|
| msg68487 - (view) | Author: A.M. Kuchling (akuchling) * (Python committer) | Date: 2008年06月20日 23:34 | |
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.
|
|||
| msg68538 - (view) | Author: Bruno Gola (brunogola) | Date: 2008年06月21日 20:26 | |
The following patch fixes the behavior, .append and .insert will accept only integer as parameters. Is this really the desired behavior? I mean, why not to accept a character for both methods? There are two tests in Lib/test/test_io.py that uses the old behavior for .append(). |
|||
| msg69856 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2008年07月16日 23:32 | |
Fixed in 2.6 r65041, and 3k r65043. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:35 | admin | set | github: 47406 |
| 2008年07月16日 23:32:47 | georg.brandl | set | status: open -> closed resolution: fixed messages: + msg69856 nosy: + georg.brandl |
| 2008年06月21日 20:26:19 | brunogola | set | files:
+ issue3156.patch nosy: + brunogola messages: + msg68538 keywords: + patch |
| 2008年06月20日 23:34:59 | akuchling | create | |