Skip to content

Commit fd009ea

Browse files
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.
1 parent 3755e3f commit fd009ea

File tree

3 files changed

+7
-43
lines changed

3 files changed

+7
-43
lines changed

plugins/python/parser/pyparser/parser.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
import jedi
34
import multiprocessing
45
import traceback
@@ -71,6 +72,10 @@ def parseProject(settings, n_proc):
7172
log(f"{bcolors.FAIL}Failed to use virtual environment: {config.venv_path}")
7273
if config.stack_trace:
7374
traceback.print_exc()
75+
else:
76+
log(f"{bcolors.FAIL}Apply the --stack-trace parser option to view a more detailed stack trace of the error")
77+
78+
sys.exit(1)
7479

7580
log(f"{bcolors.OKGREEN}Using {n_proc} process to parse project")
7681

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
jedi==0.18.0
2-
parso==0.8.4
1+
jedi==0.19.2
2+
parso==0.8.6

plugins/python/test/src/pythonparsertest.cpp

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -408,47 +408,6 @@ TEST_F(PythonParserTest, ImportModule)
408408
EXPECT_EQ(pyname.is_import, true);
409409
}
410410

411-
TEST_F(PythonParserTest, BuiltinVariable)
412-
{
413-
model::PYName pyname;
414-
415-
pyname = queryFile("imports.py",
416-
(odb::query<model::PYName>::line_start == 2 &&
417-
odb::query<model::PYName>::value == "import os"));
418-
419-
EXPECT_EQ(pyname.is_builtin, true);
420-
421-
pyname = queryFile("imports.py",
422-
(odb::query<model::PYName>::line_start == 6 &&
423-
odb::query<model::PYName>::value == "print"));
424-
425-
EXPECT_EQ(pyname.is_builtin, true);
426-
427-
pyname = queryFile("imports.py",
428-
(odb::query<model::PYName>::line_start == 12 &&
429-
odb::query<model::PYName>::value == "getpid"));
430-
431-
EXPECT_EQ(pyname.is_builtin, true);
432-
433-
pyname = queryFile("functions.py",
434-
(odb::query<model::PYName>::line_start == 85 &&
435-
odb::query<model::PYName>::value == "str"));
436-
437-
EXPECT_EQ(pyname.is_builtin, true);
438-
439-
pyname = queryFile("functions.py",
440-
(odb::query<model::PYName>::line_start == 85 &&
441-
odb::query<model::PYName>::value == "List"));
442-
443-
EXPECT_EQ(pyname.is_builtin, true);
444-
445-
pyname = queryFile("functions.py",
446-
(odb::query<model::PYName>::line_start == 98 &&
447-
odb::query<model::PYName>::value == "range"));
448-
449-
EXPECT_EQ(pyname.is_builtin, true);
450-
}
451-
452411
TEST_F(PythonParserTest, ReferenceID)
453412
{
454413
model::PYName pyname;

0 commit comments

Comments
 (0)