diff options
-rw-r--r-- | pyserial/CHANGES.txt | 1 | ||||
-rw-r--r-- | pyserial/examples/scanwin32.py | 13 | ||||
-rw-r--r-- | pyserial/serial/serialutil.py | 2 |
3 files changed, 11 insertions, 5 deletions
diff --git a/pyserial/CHANGES.txt b/pyserial/CHANGES.txt index 4c93c10..22bf7aa 100644 --- a/pyserial/CHANGES.txt +++ b/pyserial/CHANGES.txt @@ -318,3 +318,4 @@ Bugfixes (win32): - [Bug 2469098] parity PARITY_MARK, PARITY_SPACE isn't supported on win32 - [SF 2446218] outWaiting implemented +- [Bug 2392892] scanwin32.py better exception handling diff --git a/pyserial/examples/scanwin32.py b/pyserial/examples/scanwin32.py index eb5f544..43316ac 100644 --- a/pyserial/examples/scanwin32.py +++ b/pyserial/examples/scanwin32.py @@ -172,7 +172,10 @@ def comports(available_only=True): # Ignore ERROR_INSUFFICIENT_BUFFER if ctypes.GetLastError() != ERROR_INSUFFICIENT_BUFFER: raise ctypes.WinError() - port_name = re.search(r"\((.*)\)", szFriendlyName.value).group(1) + try: + port_name = re.search(r"\((.*)\)", szFriendlyName.value).group(1) + except AttributeError,msg: + port_name = "???" yield port_name, szFriendlyName.value, szHardwareID.value SetupDiDestroyDeviceInfoList(g_hdi) @@ -181,9 +184,11 @@ def comports(available_only=True): if __name__ == '__main__': import serial for port, desc, hwid in comports(): - print "%s: %s (%s)" % (port, desc, hwid) - print " "*10, serial.Serial(port) #test open - + try: + print "%s: %s (%s)" % (port, desc, hwid) + print " "*10, serial.Serial(port) #test open + except serial.serialutil.SerialException: + print "can't be openend." # list of all ports the system knows print "-"*60 for port, desc, hwid in comports(False): diff --git a/pyserial/serial/serialutil.py b/pyserial/serial/serialutil.py index 8bb18b0..fc92fa1 100644 --- a/pyserial/serial/serialutil.py +++ b/pyserial/serial/serialutil.py @@ -176,7 +176,7 @@ class SerialBase(FileLike): # - - - - - - - - - - - - - - - - - - - - - - - - - # TODO: these are not realy needed as the is the BAUDRATES etc attribute... + # TODO: these are not really needed as the is the BAUDRATES etc. attribute... # maybe i remove them before the final release... def getSupportedBaudrates(self): |