Author akuchling
Recipients akuchling
Date 2008-06-20.23:34:58
SpamBayes Score 0.000897012
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.000897012
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