adafruit/Adafruit-Raspberry-Pi-Python-Code — pull request #92 by mpgszhyh (2014-08-10 12:17:09+00:00)
Title: Fixed direction in the config function

I think that the function _readandchangepin will return a 8-bit data, but the variant self.direction is a 16-bit one. Therefore, the original code will lead to losing the direction information of PORT B by masking off the most significant byte of the variant self.direction. Maybe the code should be changed as below.
change the code in Line 95:
self.direction = self._readandchangepin(MCP23017_IODIRA, pin, mode)
to
self.direction |= self._readandchangepin(MCP23017_IODIRA, pin, mode)