#26 Allow zero-length reads

closed
Chris Liechti
5
2014-08-04
2012-02-13
No

Every now and then I stumbled across the dreaded 'serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected?)'. I finally bit the bullet and tracked it down to an inadvertent read() with a length of 0. While this is strictly a user error, the exception hints in a wrong direction.
I's suggest to either disallow them (and raise an appropriate exception) or just return what was requested, i.e., a zero-length string or bytearray.

Discussion

  • Chris Liechti
    Chris Liechti
    2012-08-16

    I don't think this problem should occur anymore (pySerial 2.7/SVN). The current implementation uses this:
    while len(read) < size: ...
    which should work as expected with read(0), returning an empty string/bytes

     
  • Chris Liechti
    Chris Liechti
    2012-08-16

    • assigned_to: nobody --> cliechti
    • status: open --> pending
     
  • Chris Liechti
    Chris Liechti
    2014-08-04

    • status: pending --> closed
    • Group: --> Next Release (example)