def open(self):
        """Open port with current settings. This may throw a SerialException
           if the port cannot be opened."""
        if self._port is None:
            raise SerialException(
                "Port must be configured before it can be used.")
        if self._isOpen:
            raise SerialException("Port is already open.")
        self.fd = None
        # open
        try:
            self.fd = os.open(self.portstr, os.O_RDWR |
                              os.O_NOCTTY | os.O_NONBLOCK)
        except Exception as msg:
            self.fd = None
            raise SerialException(
                (self._port, msg) % "could not open port %s: %s")
        #~ fcntl.fcntl(self.fd, FCNTL.F_SETFL, 0)  # set blocking
        try:
            self._reconfigurePort()
        except:
            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:
            self._isOpen = True
        #~ self.flushInput()
dataset/ETHPy150Open gepd/Deviot/libs/pyserial/serialposix.py/PosixSerial.open/swapped operands of `%`