#120 python3.2 -m serial.tools.list_ports error

v2.6
closed-fixed
None
5
2013-10-12
2012-04-16
Arno Wagner
No

Hi, this fails because of a str-pattern applied to binary text application. A patch that should work for 2.x as well is below:
-----------------
diff tools_org/list_ports_posix.py tools/list_ports_posix.py
-----------------
4a5
> import sys
44c45,49
< m = re.search(regexp, text)
---
> # text is bytes-like
> if sys.version < '3':
> m = re.search(regexp, text)
> else:
> m = re.search(regexp, text.decode('ascii'))

Discussion

  • Arno Wagner

    Arno Wagner - 2012-04-16

    Argggh, I hate auto-format. I hope this is clear enough, since I seem to be unable to add a file with the patch and the correct indention. It is really just an if-then-else on sys,version.

     
  • Arno Wagner

    Arno Wagner - 2012-04-16

    Patch

     
  • Arno Wagner

    Arno Wagner - 2012-04-16

    And found the file upload. Sorry.

     
  • Anonymous - 2012-07-12

    I'm also seeing this problem. The problem occurs when the code runs an external process, then attempts to search the results. The subprocess call doesn't guarantee the return type, as it's system/app dependent. And re can't search a bytes object for a unicode string, since doesn't know the encoding.

     
  • Chris Liechti

    Chris Liechti - 2012-08-16

    Thanks, implemented as suggested (added 'replace' as error handling for decode() in case some non-ASCII char appear in the text)

     
  • Chris Liechti

    Chris Liechti - 2012-08-16
    • assigned_to: nobody --> cliechti
    • status: open --> pending-fixed
     
  • Chris Liechti

    Chris Liechti - 2013-10-12
    • status: pending-fixed --> closed-fixed
    • Group: --> v2.6
     
  • Chris Liechti

    Chris Liechti - 2013-10-12

    r455

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks