[Bug 1470314] [NEW] serial.tools.list_ports.comports() does not work

Hua Yanghao huayanghao at gmail.com
Wed Jul 1 02:59:02 UTC 2015


Public bug reported:

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 at grass:~ $ apt-cache show python3-serial
Package: python3-serial
Priority: optional
Section: python
Installed-Size: 281
Maintainer: Ubuntu Developers <ubuntu-devel-discuss at lists.ubuntu.com>
Original-Maintainer: Matthias Klose <doko at debian.org>
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

** Affects: pyserial (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to pyserial in Ubuntu.
https://bugs.launchpad.net/bugs/1470314

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

Status in pyserial package in Ubuntu:
  New

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 at grass:~ $ apt-cache show python3-serial
  Package: python3-serial
  Priority: optional
  Section: python
  Installed-Size: 281
  Maintainer: Ubuntu Developers <ubuntu-devel-discuss at lists.ubuntu.com>
  Original-Maintainer: Matthias Klose <doko at debian.org>
  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

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/pyserial/+bug/1470314/+subscriptions



More information about the foundations-bugs mailing list