From d3919081ab599bdb17e476fe3049f8f7451dd893 Mon Sep 17 00:00:00 2001 From: cliechti Date: Thu, 16 Aug 2012 02:13:53 +0000 Subject: improve python 3 compatibility [Bug 3518380] git-svn-id: http://svn.code.sf.net/p/pyserial/code/trunk/pyserial@455 f19166aa-fa4f-0410-85c2-fa1106f25c8a --- serial/tools/list_ports_posix.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'serial') diff --git a/serial/tools/list_ports_posix.py b/serial/tools/list_ports_posix.py index 7913d81..974c037 100644 --- a/serial/tools/list_ports_posix.py +++ b/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) -- cgit v1.2.1