Skip to content

TypeError in virtualenv 20.33.0: expected string or bytes-like object, got 'list' #2930

@tomeroszlak

Description

@tomeroszlak

Issue

We're experiencing a breaking issue with virtualenv==20.33.0 when used by Poetry to create ephemeral environments. The following error occurs:

TypeError: expected string or bytes-like object, got 'list'

The traceback shows the error originates from:

  File ".venv/lib/python3.11/site-packages/virtualenv/activation/via_template.py", line 33, in quote
    return shlex.quote(string)

It appears that a list is being passed into shlex.quote() during activation template generation, instead of a string.

Expected behavior: virtualenv should sanitize or validate the inputs to shlex.quote() to ensure they are strings.

This does not happen in version 20.32.0 — pinning to that version resolves the issue. Only 20.33.0 is affected.

Environment

Provide at least:

  • OS: Ubuntu 20.04 (Dockerized Jenkins agent running as root)

  • pip list of the host python where virtualenv is installed:

    Package         Version
    --------------- -------
    pip             24.0
    poetry          1.8.2
    setuptools      69.2.0
    virtualenv      20.33.0

Output of the virtual environment creation

Make sure to run the creation with -vvv --with-traceback:

[virtualenv:virtualenv.run.session] ============================== target debug ==============================
[virtualenv:virtualenv.run.session] add activators for Bash, CShell, Fish, Nushell, PowerShell, Python

  Stack trace:

   ...
   File ".venv/lib/python3.11/site-packages/virtualenv/activation/via_template.py", line 33, in quote
     return shlex.quote(string)

TypeError: expected string or bytes-like object, got 'list'

Notes

  • Python version: 3.11.9 (via pyenv)
  • Fails during installation of a package via Poetry
  • Works when downgrading to virtualenv 20.32.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions