[NumPy-Tickets] [NumPy] #1925: output of b'\x00' is an empty bytes object

NumPy Trac numpy-tickets@scipy....
Thu Aug 4 08:09:34 CDT 2011


#1925: output of b'\x00' is an empty bytes object
--------------------+-------------------------------------------------------
 Reporter:  skrah   |       Owner:  somebody   
     Type:  defect  |      Status:  new        
 Priority:  normal  |   Milestone:  Unscheduled
Component:  Other   |     Version:  1.6.0      
 Keywords:          |  
--------------------+-------------------------------------------------------
 I'm not sure if packing a buffer directly via the struct module
 is supported. I came across this corner case:

 {{{
 >>> import struct
 >>> buf = bytearray(2)
 >>> struct.pack_into("c", buf, 0, b'\x00')
 >>> struct.pack_into("c", buf, 1, b'\x01')
 >>> nd = ndarray(buffer=buf, shape=[2], dtype="c")
 >>> nd.tolist()
 [b'', b'\x01']
 >>> struct.unpack_from("c", buf, 0)
 (b'\x00',)
 >>> struct.unpack_from("c", buf, 1)
 (b'\x01',)
 }}}


 The first character in the tolist() representation should be b'\x00'.

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1925>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list