Skip to content

Assign tuple to list slice (sys.path[:]) causes problem in pypy #15960

@Alkaid-Benetnash

Description

@Alkaid-Benetnash

Environment data

  • VS Code version: 1.55.2
  • Extension version (available under the Extensions sidebar): v2021.3.680753044
  • OS and version: archlinux 5.11.13
  • Python version (& distribution if applicable, e.g. Anaconda): pypy3 (based on Python 3.7.10, PyPy 7.3.4)
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: N/A
  • Relevant/affected Python-related VS Code extensions and their versions: N/A
  • Value of the python.languageServer setting: jedi

Expected behaviour

vscode-python can recognize the pypy3 as a valid interpreter.

Actual behaviour

It reports "The Python path in your debug configuration is invalid".
The status bar also indicates "select python interpreter" (even if I already specified one in settings.json).

Steps to reproduce:

  1. Install pypy3 (i.e. pacman -S pypy3 in archlinux)
  2. Select pypy3 as the python interpreter

Logs

I already triaged the problem to be

cd ${HOME}/.vscode/extensions/ms-python.python-2021.3.680753044/pythonFiles
pypy3 pyvsc-run-isolated.py interpreterInfo.py
# has the error ModuleNotFoundError: No module named 'json'

The reason is this line. The sys.path[:] is assigned to be a tuple, which somehow makes sys.path an empty list. I don't understand why a tuple is assigned to a list slice, nor why pypy3 behaves like this.

Changing this line to:
sys.path[:] = [p for p in sys.path if p != "" and normalize(p) != cwd]
solved the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-editor-*User-facing catch-allbugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions