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

BadSourceException being raised #65

Closed
brettcannon opened this issue Sep 6, 2018 · 2 comments
Closed

BadSourceException being raised #65

brettcannon opened this issue Sep 6, 2018 · 2 comments
Assignees
Labels
bug Something isn't working priority:P1
Milestone

Comments

@brettcannon
Copy link
Member

microsoft/vscode-python#2501

Reloading modules...

Unhandled Exception: Microsoft.PythonTools.Parsing.BadSourceException: Exception of type 'Microsoft.PythonTools.Parsing.BadSourceException' was thrown.
   at Microsoft.PythonTools.Interpreter.Ast.AstPythonInterpreter.ImportModule(String name)
   at Microsoft.PythonTools.Interpreter.Ast.AstNestedPythonModule.GetModule()
   at Microsoft.PythonTools.Interpreter.Ast.AstNestedPythonModule.GetChildrenModules()
   at Microsoft.PythonTools.Analysis.ModuleTable.ReInit()
   at Microsoft.PythonTools.Analysis.LanguageServer.Server.Interpreter_ModuleNamesChanged(Object sender, EventArgs e)
   at Microsoft.PythonTools.Interpreter.Ast.AstPythonInterpreterFactory.NotifyImportNamesChanged()
   at Microsoft.PythonTools.Analysis.PythonAnalyzer.ReloadModulesAsync(CancellationToken token)
   at Microsoft.PythonTools.Analysis.LanguageServer.Server.ReloadModulesQueueItem.Analyze(CancellationToken cancel)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.PythonTools.Analysis.LanguageServer.Server.ReloadModulesAsync(CancellationToken token)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
[Info  - 3:42:56 PM] Connection to server got closed. Server will restart.
Initializing for /home/cllamach/.virtualenvs/panopta_env/bin/python
@MikhailArkhipov MikhailArkhipov self-assigned this Sep 13, 2018
@MikhailArkhipov MikhailArkhipov added this to the Sep 2018 milestone Sep 13, 2018
@MikhailArkhipov MikhailArkhipov added bug Something isn't working priority:P1 labels Sep 13, 2018
@MikhailArkhipov
Copy link

BadSourceException means file contains characters that are out of declared encoding. Such as characters over 0x7F in file that is considered ASCII.

defaultEncoding = version.Is2x() ? PythonAsciiEncoding.Instance : Encoding.UTF8

@MikhailArkhipov
Copy link

No need to convert in any special way since host/client (VS Code) will open py files as all others, in UTF-8, will convert them to Unicode and give LS the buffer. It is possible in VSC to enter any character in the file irrespective to what version of Python is currently selected and save the file. So there is no need to do any special checks on files that LS may be opening on its own (such as imports).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working priority:P1
Projects
None yet
Development

No branches or pull requests

2 participants