Menu

#38 list_ports_osx.py Python3 compatibility

v2.7
closed-accepted
list_ports (1)
5
2015-08-04
2015-01-14
No

I found a problem with the list_ports tool for osx when run in Python3. Took awhile to find why it wasn't working but there are only 2 lines that need changed to make it Python3 compatible.

With Python3 all strings are Unicode. When interfacing with Mac's IOKit dll you must send strings as ASCII which was fine with Python2 because that was how strings were encoded with Python2. To get it working you just need to change line 176 in list_ports_osx.py from

services = GetIOServicesByType('IOSerialBSDClient')
to
services = GetIOServicesByType('IOSerialBSDClient'.encode('ascii'))

Then you'll also want to change the print statement on line 209 but it's not completely necessary. I've attached and updated version of file with the above changes.

Sorry if this is in the wrong place. I'm not too familiar with SVN and SourceForge

1 Attachments

Related

Patches: #36

Discussion

  • Caleb Coffie

    Caleb Coffie - 2015-01-15

    I made a few more corrections. Attached is the updated version.

     
  • Caleb Coffie

    Caleb Coffie - 2015-01-15

    It was was returning bytes rather than a string. I have fixed that with the attached file.

     
  • Chris Liechti

    Chris Liechti - 2015-08-04
    • status: open --> closed-accepted
    • assigned_to: Chris Liechti
     
  • Chris Liechti

    Chris Liechti - 2015-08-04
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.