[NumPy-Tickets] [NumPy] #1943: numpy.frombuffer fails when given an empty buffer

NumPy Trac numpy-tickets@scipy....
Thu Aug 25 08:58:42 CDT 2011

#1943: numpy.frombuffer fails when given an empty buffer
 Reporter:  hniksic  |       Owner:  somebody   
     Type:  defect   |      Status:  new        
 Priority:  normal   |   Milestone:  Unscheduled
Component:  Other    |     Version:  1.5.1      
 Keywords:           |  
 numpy.frombuffer raises an exception when given an empty buffer, where one
 would expect it to return an empty array of given dtype.  For example:

 >>> import array, numpy as np
 >>> np.frombuffer(array.array('d'))
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
 ValueError: offset must be non-negative and smaller than buffer lenth (0)

 This requires code converting buffers to numpy arrays to special-case
 empty buffers.  Furthermore, the problem is often not discovered until
 someone actually passes a zero-sized buffer to the code that calls
 frombuffer, and trips over this exception at run-time.

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

More information about the NumPy-Tickets mailing list