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.

Author akuchling
Recipients akuchling
Date 2008-06-20.23:34:58
SpamBayes Score 0.0008970118
Marked as misclassified No
Message-id <1214004899.96.0.722439580753.issue3156@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2008-06-20 23:35:00akuchlingsetspambayes_score: 0.000897012 -> 0.0008970118
recipients: + akuchling
2008-06-20 23:35:00akuchlingsetspambayes_score: 0.000897012 -> 0.000897012
messageid: <1214004899.96.0.722439580753.issue3156@psf.upfronthosting.co.za>
2008-06-20 23:34:58akuchlinglinkissue3156 messages
2008-06-20 23:34:58akuchlingcreate