Skip to content

SigrokDriver.stop() passes str to Popen.communicate() with binary stdin (Python 3.11+) #1847

@xistadi

Description

@xistadi

SigrokDriver.stop() in labgrid/driver/sigrokdriver.py calls:

stdout, stderr = self._process.communicate(input="q")

The sigrok-cli process is started via _call_with_driver() / _call() with stdin=subprocess.PIPE and without text=True / universal_newlines=True, so stdin is in binary mode. For such a Popen instance, communicate(input=...) must receive bytes, not str.

On Python 3.11+ (Linux), this raises:

TypeError: memoryview: a bytes-like object is required, not 'str'
(stack trace points at subprocess.py inside _communicate, when handling input).

Steps to reproduce

  1. Use Labgrid’s SigrokDriver to run capture() then stop() (e.g. continuous capture with sigrok-cli).
  2. Run on Python ≥ 3.11 on Linux.

Expected behavior
stop() should shut down sigrok-cli without a TypeError (e.g. send quit as bytes).

Suggested fix
Use bytes for the quit character, e.g.:

stdout, stderr = self._process.communicate(input=b"q")

stdout, stderr = self._process.communicate(input="q")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions