From fd009eae55bd3796ef2ff575823ffd53c71a4958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20Domozi?= Date: Wed, 18 Mar 2026 17:45:05 +0100 Subject: [PATCH] Fix Python plugin venv loading Changes: - Updated the Python parser's dependencies to the latest version since newer Python versions require a more recent version of the Jedi parsing library to load the Python virtual environment (venv). - Minor fix: failing to load a virtual environment is a major misconfiguration issue, so the parser now exits with and error. - Removed PYBuiltin test case: these test cases have been flaky for some time, especially after the library version updates. Since whether a node is built-in is only shown in the info tree, this feature is not critical and was implemented back then as a nice-to-have. --- plugins/python/parser/pyparser/parser.py | 5 +++ plugins/python/parser/requirements.txt | 4 +- plugins/python/test/src/pythonparsertest.cpp | 41 -------------------- 3 files changed, 7 insertions(+), 43 deletions(-) diff --git a/plugins/python/parser/pyparser/parser.py b/plugins/python/parser/pyparser/parser.py index 3201c3eb4..73f46d9ff 100644 --- a/plugins/python/parser/pyparser/parser.py +++ b/plugins/python/parser/pyparser/parser.py @@ -1,4 +1,5 @@ import os +import sys import jedi import multiprocessing import traceback @@ -71,6 +72,10 @@ def parseProject(settings, n_proc): log(f"{bcolors.FAIL}Failed to use virtual environment: {config.venv_path}") if config.stack_trace: traceback.print_exc() + else: + log(f"{bcolors.FAIL}Apply the --stack-trace parser option to view a more detailed stack trace of the error") + + sys.exit(1) log(f"{bcolors.OKGREEN}Using {n_proc} process to parse project") diff --git a/plugins/python/parser/requirements.txt b/plugins/python/parser/requirements.txt index 18d880e9d..a80770b57 100644 --- a/plugins/python/parser/requirements.txt +++ b/plugins/python/parser/requirements.txt @@ -1,2 +1,2 @@ -jedi==0.18.0 -parso==0.8.4 +jedi==0.19.2 +parso==0.8.6 diff --git a/plugins/python/test/src/pythonparsertest.cpp b/plugins/python/test/src/pythonparsertest.cpp index c656e4b29..fcf36b223 100644 --- a/plugins/python/test/src/pythonparsertest.cpp +++ b/plugins/python/test/src/pythonparsertest.cpp @@ -408,47 +408,6 @@ TEST_F(PythonParserTest, ImportModule) EXPECT_EQ(pyname.is_import, true); } -TEST_F(PythonParserTest, BuiltinVariable) -{ - model::PYName pyname; - - pyname = queryFile("imports.py", - (odb::query::line_start == 2 && - odb::query::value == "import os")); - - EXPECT_EQ(pyname.is_builtin, true); - - pyname = queryFile("imports.py", - (odb::query::line_start == 6 && - odb::query::value == "print")); - - EXPECT_EQ(pyname.is_builtin, true); - - pyname = queryFile("imports.py", - (odb::query::line_start == 12 && - odb::query::value == "getpid")); - - EXPECT_EQ(pyname.is_builtin, true); - - pyname = queryFile("functions.py", - (odb::query::line_start == 85 && - odb::query::value == "str")); - - EXPECT_EQ(pyname.is_builtin, true); - - pyname = queryFile("functions.py", - (odb::query::line_start == 85 && - odb::query::value == "List")); - - EXPECT_EQ(pyname.is_builtin, true); - - pyname = queryFile("functions.py", - (odb::query::line_start == 98 && - odb::query::value == "range")); - - EXPECT_EQ(pyname.is_builtin, true); -} - TEST_F(PythonParserTest, ReferenceID) { model::PYName pyname;