-
Notifications
You must be signed in to change notification settings - Fork 133
Debug assertion when opening some files with relative imports #291
Description
I wouldn't open this except that it fails in a debug build, which I assume means that it's a pretty unexpected error.
My environment:
macOS 10.14
VSCode 1.28.2
Python Extension, 2018.9.1, with trace logging enabled
A debug build of the python-language-server (mine's at 6d4659f)
Take the following archive: test.tar.gz and extract it somewhere (~/code). Open the folder (~/code/test) in VSCode, and then, as strange as this seems, use the explorer and open all the files in order, from the bottom up.
In other words, open util.py, main.py, lib/util.py, lib/test.py, and then lib/__init__.py. Then, observe the Python output window:
Failed to get module test we just imported
at Microsoft.PythonTools.Analysis.Analyzer.DDG.Walk(ImportStatement node) in /Users/username/code/python-language-server/src/Analysis/Engine/Impl/Analyzer/DDG.cs:line 568
at Microsoft.PythonTools.Parsing.Ast.ImportStatement.Walk(PythonWalker walker) in /Users/username/code/python-language-server/src/Analysis/Engine/Impl/Parsing/Ast/ImportStatement.cs:line 65
at Microsoft.PythonTools.Analysis.Analyzer.DDG.Walk(SuiteStatement node) in /Users/username/code/python-language-server/src/Analysis/Engine/Impl/Analyzer/DDG.cs:line 666
at Microsoft.PythonTools.Parsing.Ast.SuiteStatement.Walk(PythonWalker walker) in /Users/username/code/python-language-server/src/Analysis/Engine/Impl/Parsing/Ast/SuiteStatement.cs:line 34
at Microsoft.PythonTools.Parsing.Ast.PythonAst.Walk(PythonWalker walker) in /Users/username/code/python-language-server/src/Analysis/Engine/Impl/Parsing/Ast/PythonAst.cs:line 92
at Microsoft.PythonTools.Analysis.AnalysisUnit.AnalyzeWorker(DDG ddg, CancellationToken cancel) in /Users/username/code/python-language-server/src/Analysis/Engine/Impl/AnalysisUnit.cs:line 154
at Microsoft.PythonTools.Analysis.AnalysisUnit.Analyze(DDG ddg, CancellationToken cancel) in /Users/username/code/python-language-server/src/Analysis/Engine/Impl/AnalysisUnit.cs:line 139
at Microsoft.PythonTools.Analysis.Analyzer.DDG.Analyze(Deque`1 queue, CancellationToken cancel, Action`1 reportQueueSize, Int32 reportQueueInterval) in /Users/username/code/python-language-server/src/Analysis/Engine/Impl/Analyzer/DDG.cs:line 75
at Microsoft.PythonTools.Analysis.PythonAnalyzer.AnalyzeQueuedEntries(CancellationToken cancel) in /Users/username/code/python-language-server/src/Analysis/Engine/Impl/PythonAnalyzer.cs:line 924
at Microsoft.PythonTools.Intellisense.AnalysisQueue.GroupAnalysis.Analyze(CancellationToken cancel) in /Users/username/code/python-language-server/src/Analysis/Engine/Impl/Intellisense/AnalysisQueue.cs:line 229
at Microsoft.PythonTools.Intellisense.AnalysisQueue.HandleAnalyzable(IAnalyzable item, AnalysisPriority priority, CancellationToken cancellationToken) in /Users/username/code/python-language-server/src/Analysis/Engine/Impl/Intellisense/AnalysisQueue.cs:line 152
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.PythonTools.Intellisense.AnalysisQueue.HandleAnalyzable(IAnalyzable item, AnalysisPriority priority, CancellationToken cancellationToken)
at Microsoft.PythonTools.Intellisense.AnalysisQueue.<>c__DisplayClass31_0.<Enqueue>b__0(CancellationToken ct) in /Users/username/code/python-language-server/src/Analysis/Engine/Impl/Intellisense/AnalysisQueue.cs:line 136
at Microsoft.PythonTools.Intellisense.AnalysisQueue.ConsumerLoop() in /Users/username/code/python-language-server/src/Analysis/Engine/Impl/Intellisense/AnalysisQueue.cs:line 64
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext()
at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(IAsyncStateMachineBox box, Boolean allowInlining)
at System.Threading.Tasks.Task.RunContinuations(Object continuationObject)
at System.Threading.Tasks.Task`1.TrySetResult(TResult result)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.SetExistingTaskResult(TResult result)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.SetResult(TResult result)
at Microsoft.PythonTools.Intellisense.AnalysisQueue.ConsumeAsync() in /Users/username/code/python-language-server/src/Analysis/Engine/Impl/Intellisense/AnalysisQueue.cs:line 89
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
[Info - 1:24:51 PM] Connection to server got closed. Server will restart.
[Error - 1:24:51 PM] Request textDocument/documentSymbol failed.
A very cursory debugging seems to show that the lookup fails because the ModuleTable has an entry for 'lib.test' rather than 'test', but I don't know if that's actually the culprit, or if that's even a problem.