summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2012-08-16 02:13:53 +0000
committercliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2012-08-16 02:13:53 +0000
commitec5c636cce8572932472e26a519640d7f938c07c (patch)
tree38aad5a537ee6cf7a3b4c8c2f01d19bdacc1119a
parent4b20ec6498f586cbbebe9f4feb0c6f3724ede773 (diff)
downloadpyserial-git-ec5c636cce8572932472e26a519640d7f938c07c.tar.gz
improve python 3 compatibility [Bug 3518380]
-rw-r--r--pyserial/CHANGES.txt1
-rw-r--r--pyserial/serial/tools/list_ports_posix.py6
2 files changed, 6 insertions, 1 deletions
diff --git a/pyserial/CHANGES.txt b/pyserial/CHANGES.txt
index 8a8e224..8359d28 100644
--- a/pyserial/CHANGES.txt
+++ b/pyserial/CHANGES.txt
@@ -450,6 +450,7 @@ Bugfixes (posix):
- [Patch 3462364] Fix: NameError: global name 'base' is not defined
- list_ports and device() for BSD updated (Anders Langworthy)
+- [Bug 3518380] python3.2 -m serial.tools.list_ports error
Bugfixes (win32):
diff --git a/pyserial/serial/tools/list_ports_posix.py b/pyserial/serial/tools/list_ports_posix.py
index 7913d81..974c037 100644
--- a/pyserial/serial/tools/list_ports_posix.py
+++ b/pyserial/serial/tools/list_ports_posix.py
@@ -41,7 +41,11 @@ def read_line(filename):
def re_group(regexp, text):
"""search for regexp in text, return 1st group on match"""
- m = re.search(regexp, text)
+ if sys.version < '3':
+ m = re.search(regexp, text)
+ else:
+ # text is bytes-like
+ m = re.search(regexp, text.decode('ascii', 'replace'))
if m: return m.group(1)