serial.tools.list_ports.comports() does not work

Bug #1470314 reported by Hua Yanghao
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
pyserial (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

The issue is present with both python-serial and python3-serial (ubuntu 15.04), where you got a trace back like below if you want to use list_ports.comports() (or the grep function):
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/serial/tools/list_ports_posix.py", line 122, in comports
    return [(d, describe(d), hwinfo(d)) for d in devices]
  File "/usr/lib/python3/dist-packages/serial/tools/list_ports_posix.py", line 122, in <listcomp>
    return [(d, describe(d), hwinfo(d)) for d in devices]
  File "/usr/lib/python3/dist-packages/serial/tools/list_ports_posix.py", line 93, in describe
    return usb_lsusb_string(sys_usb)
  File "/usr/lib/python3/dist-packages/serial/tools/list_ports_posix.py", line 80, in usb_lsusb_string
    return base
NameError: name 'base' is not defined

The fix is also very simple (but not sure if this can be a valid fix):
In file: "/usr/lib/python2.7/dist-packages/serial/tools/list_ports_posix.py"
Line: 67, change it to below:
66 def usb_lsusb_string(sysfs_path):
 67 base = os.path.basename(os.path.realpath(sysfs_path))
 68 bus, dev = base.split('-')

So that "base" is properly defined and can be returned.

Attached the version info from apt-show:
hua@grass:~ $ apt-cache show python3-serial
Package: python3-serial
Priority: optional
Section: python
Installed-Size: 281
Maintainer: Ubuntu Developers <email address hidden>
Original-Maintainer: Matthias Klose <email address hidden>
Architecture: all
Source: pyserial
Version: 2.6-1.1ubuntu1
Depends: python3, python3:any (>= 3.3.2-2~)
Suggests: python3-wxgtk3.0 | python3-wxgtk
Filename: pool/main/p/pyserial/python3-serial_2.6-1.1ubuntu1_all.deb
Size: 44348
MD5sum: 749c10727018f02830d2ea704a97e3a9
SHA1: 67dcb133ec940f6ee8a0e9a531adeca2e5d445e3
SHA256: 0f6111b350e901ebafd69945eec47efad4b6dabf1be8e6dc6dab254f72f2d422
Description-en: pyserial - module encapsulating access for the serial port
 This module encapsulates the access for the serial port. It provides
 back-ends for standard Python running on Windows, Linux, BSD (possibly
 any POSIX compliant system). The module named "serial" automatically
 selects the appropriate back-end.
Description-md5: 4dab91c4e71dab549f66bda57e2ecc69
Homepage: http://pyserial.sourceforge.net/
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 9m
Task: ubuntu-core, cloud-image, ubuntu-core

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in pyserial (Ubuntu):
status: New → Confirmed
Revision history for this message
Alex (alexthreed) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.