Tino de Bruijn avatar Tino de Bruijn committed 7209fbf

Fixed bug where a TypeError would not be caught when too much data was received

Comments (0)

Files changed (2)

pyfirmata/pyfirmata.py

             return False
         try:
             handler(*data)
-        except ValueError, TypeError:
+        except (ValueError, TypeError):
             # TypeError occurs when we pass to many arguments.
             # ValueError may be thrown when the received data is not correct.
             return True
         sysex = (chr(0xF0), chr(0x7), chr(1), chr(2), chr(3), chr(0xF7))
         self.assert_serial(*sysex)
         
+    def test_too_much_data(self):
+        """ 
+        ``_process_command`` should return True when too much data is given
+        for a handler.
+        """
+        res = self.board._process_command(pyfirmata.ANALOG_MESSAGE, [1, 1, 1, 1, 1])
+        self.assertTrue(res)
         
 class TestBoardLayout(BoardBaseTest):
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.