Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Python language server didn't work properly when editing '__init__.py' #572

Closed
d3r3kk opened this issue Jan 31, 2019 · 5 comments
Closed
Assignees

Comments

@d3r3kk
Copy link

d3r3kk commented Jan 31, 2019

@CamberLoid commented on Wed Jan 30 2019

Issue Type: Bug

Python language server raised an exception and caused problems when handling this import (modules),(),
After double-checking on my Windows, I am sure this is because of the extra comma in the import expression in __init__.py ,

Using Anaconda distribution. Have not tried to reproduce on other OS.

Environment data

  • Version: 1.30.2 (user setup)
  • Commit: 61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8
  • Date: 2019-01-07T22:54:13.295Z
  • Electron: 2.0.12
  • Chrome: 61.0.3163.100
  • Node.js: 8.9.3
  • V8: 6.1.534.41
  • OS: Windows_NT x64 10.0.18323

Actual behaviour

Cannot access origin libraries by Ctrl+(Modules), and the exceptions below.
It acts like this

issue

Expected behaviour

Access origin libraries by Ctrl+(Modules)
and no Exceptions

Logs

[Error - 1:18:14 AM] System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.SZArrayHelper.get_Item[T](Int32 index)
   at Microsoft.PythonTools.Analysis.Analyzer.DDG.ImportModule(ImportStatement& node, IModule& module, DottedName& moduleImportExpression, NameExpression& asNameExpression)
   at Microsoft.PythonTools.Analysis.Analyzer.DDG.Walk(ImportStatement node)
   at Microsoft.PythonTools.Parsing.Ast.ImportStatement.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(Deque`1 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()

Extension version: 2019.1.0
VS Code version: Code 1.30.2 (61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8, 2019-01-07T22:54:13.295Z)
OS version: Windows_NT x64 10.0.18323

System Info
Item Value
CPUs Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz (12 x 2208)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 15.87GB (9.36GB free)
Process Argv
Screen Reader no
VM 0%

@d3r3kk commented on Thu Jan 31 2019

Verified, here's another gif that might help figure out the issue:

4226_intellisense_exception_on_import_trailing_comma

This is using Microsoft Python Language Server version 0.1.78.0, Miniconda3 on Windows with Python 3.7.2

@d3r3kk
Copy link
Author

d3r3kk commented Jan 31, 2019

Output found in the Output:Log(Window)

[2019-01-31 14:43:51.417] [renderer1] [error] name must not be falsy: Error: name must not be falsy
	at Function.e.validate (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:357:869)
	at new e (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:357:807)
	at R (C:\Users\derek\.vscode\extensions\ms-python.python-2019.1.0\out\client\extension.js:83:93748)
	at Array.map (<anonymous>)
	at Object.asDocumentSymbols (C:\Users\derek\.vscode\extensions\ms-python.python-2019.1.0\out\client\extension.js:83:97402)
	at module.exports.R.registerLanguageProvider.t.sendRequest.then.e (C:\Users\derek\.vscode\extensions\ms-python.python-2019.1.0\out\client\extension.js:1:142452)
	at <anonymous>

Problems Window

image

@jakebailey
Copy link
Member

Aha, so that's what that stack trace is.

The diagnostics not going away are likely due to the LS exiting and leaving them there.

@jakebailey
Copy link
Member

For reference, this was likely a bug beforehand too, it's just that the latest release now will actually report the exception and exit rather than swallowing it and then silently refusing any future requests.

@MikhailArkhipov MikhailArkhipov self-assigned this Feb 6, 2019
@MikhailArkhipov
Copy link

MikhailArkhipov commented Feb 6, 2019

Verify with new LS.

@MikhailArkhipov
Copy link

Verified, there is a test for that in #602.
Fix is not in public release yet, it will be some time before it gets to public since we are in a major rework of the LS.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants