[Bug pyserial:141] open: Pass errno from IOError to SerialException
diff --git a/pyserial/serial/serialposix.py b/pyserial/serial/serialposix.py
index 1b7fe86..27c1328 100644
--- a/pyserial/serial/serialposix.py
+++ b/pyserial/serial/serialposix.py
@@ -288,9 +288,9 @@
# open
try:
self.fd = os.open(self.portstr, os.O_RDWR|os.O_NOCTTY|os.O_NONBLOCK)
- except Exception, msg:
+ except IOError, msg:
self.fd = None
- raise SerialException("could not open port %s: %s" % (self._port, msg))
+ raise SerialException(msg.errno, "could not open port %s: %s" % (self._port, msg))
#~ fcntl.fcntl(self.fd, FCNTL.F_SETFL, 0) # set blocking
try: