#30 [PATCH 1/1] serial.Serial() should not raise IOError.

v2.7
closed-fixed
None
5
2013-10-11
2013-04-09
No

According to the documentation, serial.Serial() can only raise ValueError and SerialException. This code raises an IOError:

>>> serial.Serial("/dev/pts/0", 42)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "serial/serialutil.py", line 261, in __init__
self.open()
File "serial/serialposix.py", line 285, in open
self._reconfigurePort()
File "serial/serialposix.py", line 420, in _reconfigurePort
set_special_baudrate(self, custom_baud)
File "serial/serialposix.py", line 47, in set_special_baudrate
FCNTL.ioctl(port.fd, TERMIOS.TIOCGSERIAL, buf)
IOError: [Errno 22] Invalid argument

The attached patch fixes this issue by catching the IOError in set_special_baudrate and raising a ValueError.

Discussion

  • Chris Liechti

    Chris Liechti - 2013-10-11

    Ah, it did catch the errors on write but not on read. Fix comitted.

     
  • Chris Liechti

    Chris Liechti - 2013-10-11
    • status: open --> closed-fixed
    • assigned_to: Chris Liechti
    • Group: --> v2.7
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks