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

BadSourceException being raised #65

Closed

Description

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

Activity

  1. MikhailArkhipov commented on Sep 17, 2018

    @MikhailArkhipov

    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
  2. MikhailArkhipov commented on Sep 17, 2018

    @MikhailArkhipov

    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 join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugpriority:P1

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions