diff --git a/tools/pyboard.py b/tools/pyboard.py
index 3ff694a7c8a9e49c879c344ed0a0eb7681a83167..925e16bc60bcec9248bb573134ed64c78c7439f1 100755
--- a/tools/pyboard.py
+++ b/tools/pyboard.py
@@ -128,7 +128,7 @@ class Pyboard:
                 try:
                     self.serial = serial.Serial(device, baudrate=baudrate, interCharTimeout=1)
                     break
-                except OSError, IOError: # Py2 and Py3 have different errors
+                except (OSError, IOError): # Py2 and Py3 have different errors
                     if wait == 0:
                         continue
                     if attempt == 0: