Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError in serial.tools.list_ports.comports() #406

Open
Qlexio opened this issue Jan 27, 2025 · 0 comments
Open

TypeError in serial.tools.list_ports.comports() #406

Qlexio opened this issue Jan 27, 2025 · 0 comments

Comments

@Qlexio
Copy link
Owner

Qlexio commented Jan 27, 2025

I had this issue when using our app, which is relying on pyserial. It has two threads, one reading from a serial device and a second one is frequently calling serial.tools.list_ports.comports().

During operation, it failed with this:

Traceback (most recent call last):
  File "/path/utility/SerialDevice.py", line 45, in discover_serial_devices
    ports = serial.tools.list_ports.comports()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/venv/lib/python3.11/site-packages/serial/tools/list_ports_linux.py", line 102, in comports
    for info in [SysFS(d) for d in devices]
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/venv/lib/python3.11/site-packages/serial/tools/list_ports_linux.py", line 102, in <listcomp>
    for info in [SysFS(d) for d in devices]
                 ^^^^^^^^
  File "/path/venv/lib/python3.11/site-packages/serial/tools/list_ports_linux.py", line 52, in __init__
    self.vid = int(self.read_line(self.usb_device_path, 'idVendor'), 16)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: int() can't convert non-string with explicit base

While we can swallow the exception at the calling site, I don't think serial.tools.list_ports.comports() should throw in the first place.

The hardware is a STM32 board with custom software, and I'm quite sure it misbehaved but again comports() shouldn't throw IMO. I'll try to reproduce the issue, but don't hold your breath.


This issue has been cloned from: pyserial#774

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant