With PySerial 2.7 installed on my Mac OS X computer, when I execute the following Python script:
from serial import Serial Serial('/dev/nonexistent')
the PySerial PosixSerial.open method raises an OSError. However, looking at this portion of the PosixSerial.open method:
try: self.fd = os.open(self.portstr, os.O_RDWR|os.O_NOCTTY|os.O_NONBLOCK) except IOError, msg: self.fd = None raise SerialException(msg.errno, "could not open port %s: %s" % (self._port, msg))
it appears that the intent is to raise a SerialException rather than an OSError when the call to os.open fails. This could be fixed, of course, by catching OSError exceptions instead of or in addition to IOError exceptions and responding to them in the same way.
Log in to post a comment.