Skip to content

Language Server: System.NullReferenceException: Object reference not set to an instance of an object. #2523

Closed
@RhyCynn

Description

@RhyCynn

Environment data

  • VS Code version: 1.27.1 & 1.28.0-insider (clean installs)
  • Extension version (available under the Extensions sidebar): 2018.8.0
  • OS and version: Windows 10 Pro Version 10.0.17134.228
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7 64-bit (clean install)
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): NA
  • Relevant/affected Python packages and their versions: None

Actual behavior

Output for Python in the Output panel opens with a "System.NullReferenceException" error after typing "from ." in an "__init__.py" file.

Expected behavior

No error

Steps to reproduce:

  1. Create an empty folder
  2. Open the folder with vscode or vscode-insider
  3. Create a new file "__init__.py"
  4. Start typing "from ."

The error occurs after typing the dot. The error does not occur with other file names (e.g. "some_file.py"). I cannot tell if this is related to a closed issue with a similar error.

Screenshots at the bottom.

Logs

Output for Python in the Output panel:
[Error - 8:33:17 AM] System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.PythonTools.Analysis.ModuleResolver.GetModuleFullName(String originatingModule, String relativePath)
at Microsoft.PythonTools.Analysis.ModuleResolver.ResolvePotentialModuleNames(String importingFromModuleName, String importingFromFilePath, String relativeModuleName, Boolean absoluteImports)+MoveNext()
at System.Collections.Generic.LargeArrayBuilder1.AddRange(IEnumerable1 items)
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at Microsoft.PythonTools.Analysis.Analyzer.DDG.TryImportModule(String modName, Boolean forceAbsolute, ModuleReference& moduleRef, IReadOnlyList1& remainingParts) at Microsoft.PythonTools.Analysis.Analyzer.DDG.Walk(FromImportStatement node) at Microsoft.PythonTools.Parsing.Ast.FromImportStatement.Walk(PythonWalker walker) at Microsoft.PythonTools.Analysis.Analyzer.DDG.Walk(SuiteStatement node) at Microsoft.PythonTools.Parsing.Ast.SuiteStatement.Walk(PythonWalker walker) at Microsoft.PythonTools.Parsing.Ast.PythonAst.Walk(PythonWalker walker) at Microsoft.PythonTools.Analysis.AnalysisUnit.AnalyzeWorker(DDG ddg, CancellationToken cancel) at Microsoft.PythonTools.Analysis.Analyzer.DDG.Analyze(Deque1 queue, CancellationToken cancel, Action`1 reportQueueSize, Int32 reportQueueInterval)
at Microsoft.PythonTools.Analysis.PythonAnalyzer.AnalyzeQueuedEntries(CancellationToken cancel)
at Microsoft.PythonTools.Intellisense.AnalysisQueue.GroupAnalysis.Analyze(CancellationToken cancel)
at Microsoft.PythonTools.Intellisense.AnalysisQueue.HandleAnalyzable(IAnalyzable item, AnalysisPriority priority, CancellationToken cancellationToken)
at Microsoft.PythonTools.Intellisense.AnalysisQueue.ConsumerLoop()

Output from Console under the Developer Tools panel:
None

Screenshots

vscode
vscode_dot_test_ss

vscode-insider
vscode_insider_dot_test_ss

Metadata

Metadata

Labels

area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.bugIssue 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