fix some minor issues that were uncovered when run with 3.x
diff --git a/pyserial/serial/serialposix.py b/pyserial/serial/serialposix.py
index 41bac8b..c3cc284 100644
--- a/pyserial/serial/serialposix.py
+++ b/pyserial/serial/serialposix.py
@@ -282,12 +282,17 @@
         except Exception, msg:
             self.fd = None
             raise SerialException("could not open port %s: %s" % (self._port, msg))
-        #~ fcntl.fcntl(self.fd, FCNTL.F_SETFL, 0)  #set blocking
+        #~ fcntl.fcntl(self.fd, FCNTL.F_SETFL, 0)  # set blocking
 
         try:
             self._reconfigurePort()
         except:
-            os.close(self.fd)
+            try:
+                os.close(self.fd)
+            except:
+                # ignore any exception when closing the port
+                # also to keep original exception that happened when setting up
+                pass
             self.fd = None
             raise
         else:
@@ -301,19 +306,19 @@
             raise SerialException("Can only operate on a valid port handle")
         custom_baud = None
 
-        vmin = vtime = 0                #timeout is done via select
+        vmin = vtime = 0                # timeout is done via select
         if self._interCharTimeout is not None:
             vmin = 1
             vtime = int(self._interCharTimeout * 10)
         try:
             iflag, oflag, cflag, lflag, ispeed, ospeed, cc = termios.tcgetattr(self.fd)
-        except termios.error, msg:      #if a port is nonexistent but has a /dev file, it'll fail here
+        except termios.error, msg:      # if a port is nonexistent but has a /dev file, it'll fail here
             raise SerialException("Could not configure port: %s" % msg)
         # set up raw mode / no echo / binary
         cflag |=  (TERMIOS.CLOCAL|TERMIOS.CREAD)
         lflag &= ~(TERMIOS.ICANON|TERMIOS.ECHO|TERMIOS.ECHOE|TERMIOS.ECHOK|TERMIOS.ECHONL|
                      TERMIOS.ISIG|TERMIOS.IEXTEN) #|TERMIOS.ECHOPRT
-        for flag in ('ECHOCTL', 'ECHOKE'): #netbsd workaround for Erk
+        for flag in ('ECHOCTL', 'ECHOKE'): # netbsd workaround for Erk
             if hasattr(TERMIOS, flag):
                 lflag &= ~getattr(TERMIOS, flag)
 
@@ -326,7 +331,7 @@
 
         # setup baud rate
         try:
-            ispeed = ospeed = getattr(TERMIOS,'B%s' % (self._baudrate))
+            ispeed = ospeed = getattr(TERMIOS, 'B%s' % (self._baudrate))
         except AttributeError:
             try:
                 ispeed = ospeed = baudrate_constants[self._baudrate]
@@ -392,12 +397,12 @@
                 cflag |=  (TERMIOS.CRTSCTS)
             else:
                 cflag &= ~(TERMIOS.CRTSCTS)
-        elif hasattr(TERMIOS, 'CNEW_RTSCTS'):   #try it with alternate constant name
+        elif hasattr(TERMIOS, 'CNEW_RTSCTS'):   # try it with alternate constant name
             if self._rtscts:
                 cflag |=  (TERMIOS.CNEW_RTSCTS)
             else:
                 cflag &= ~(TERMIOS.CNEW_RTSCTS)
-        #XXX should there be a warning if setting up rtscts (and xonxoff etc) fails??
+        # XXX should there be a warning if setting up rtscts (and xonxoff etc) fails??
 
         # buffer
         # vmin "minimal number of characters to be read. = for non blocking"
@@ -449,7 +454,8 @@
                     break   # timeout
                 buf = os.read(self.fd, size - len(read))
                 read.extend(buf)
-                if (self._timeout >= 0 or self._interCharTimeout > 0) and not buf:
+                if ((self._timeout is not None and self._timeout >= 0) or 
+                    (self._interCharTimeout is not None and self._interCharTimeout > 0)) and not buf:
                     break   # early abort on timeout
         return bytes(read)
 
diff --git a/pyserial/serial/serialutil.py b/pyserial/serial/serialutil.py
index 92bbcdd..38e3d89 100644
--- a/pyserial/serial/serialutil.py
+++ b/pyserial/serial/serialutil.py
@@ -11,8 +11,8 @@
     bytearray
 except AttributeError:
     # Python older than 2.6 do not have these types. Like for Python 2.6 they
-    # should behave like str.  for Python older than 3.0 we want to work with
-    # strings anyway, only later versions have a trues bytes type.
+    # should behave like str. For Python older than 3.0 we want to work with
+    # strings anyway, only later versions have a true bytes type.
     bytes = str
     # bytearray is a mutable type that is easily turned into an instance of
     # bytes
@@ -25,7 +25,11 @@
                 list.append(self, item)
             else:
                 list.append(self, chr(item))
-
+    XON  = chr(17)
+    XOFF = chr(19)
+else:
+    XON  = bytes([17])
+    XOFF = bytes([19])
 
 PARITY_NONE, PARITY_EVEN, PARITY_ODD, PARITY_MARK, PARITY_SPACE = 'N', 'E', 'O', 'M', 'S'
 STOPBITS_ONE, STOPBITS_ONE_POINT_FIVE, STOPBITS_TWO = (1, 1.5, 2)
@@ -39,9 +43,6 @@
     PARITY_SPACE: 'Space',
 }
 
-XON  = chr(17)
-XOFF = chr(19)
-
 
 class SerialException(IOError):
     """Base class for serial port related exceptions."""
@@ -236,7 +237,7 @@
 
     def setBaudrate(self, baudrate):
         """Change baud rate. It raises a ValueError if the port is open and the
-        baud rate is not possible. If the port is closed, then tha value is
+        baud rate is not possible. If the port is closed, then the value is
         accepted and the exception is raised when the port is opened."""
         try:
             self._baudrate = int(baudrate)
@@ -294,12 +295,11 @@
     def setTimeout(self, timeout):
         """Change timeout setting."""
         if timeout is not None:
-            if timeout < 0: raise ValueError("Not a valid timeout: %r" % (timeout,))
             try:
                 timeout + 1     # test if it's a number, will throw a TypeError if not...
             except TypeError:
                 raise ValueError("Not a valid timeout: %r" % (timeout,))
-
+            if timeout < 0: raise ValueError("Not a valid timeout: %r" % (timeout,))
         self._timeout = timeout
         if self._isOpen: self._reconfigurePort()