Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BadSourceException #2501

Closed
CMLL opened this issue Sep 6, 2018 · 4 comments
Closed

BadSourceException #2501

CMLL opened this issue Sep 6, 2018 · 4 comments
Labels
area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug

Comments

@CMLL
Copy link

CMLL commented Sep 6, 2018

Environment data

  • VS Code version: 1.27.1
  • Extension version (available under the Extensions sidebar): 2018.8.0
  • OS and version: Ubuntu 18.04.1
  • Python version (& distribution if applicable, e.g. Anaconda): 2.7.15rc1
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): virtualenv
  • Relevant/affected Python packages and their versions:

Actual behavior

After language server reloads modules server starts crashing with BadSourceException, it restarts itself and after a few cycles it stops restarting completely.

Expected behavior

Normal behaviour.

Steps to reproduce:

1- Open python file.
2- Edit it normally.
3- Wait for extension to crash.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

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
@brettcannon
Copy link
Member

Can you provide the source file that you are opening which is causing the crash?

@brettcannon brettcannon added bug Issue identified by VS Code Team member as probable bug area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. upstream-language server labels Sep 6, 2018
@CMLL
Copy link
Author

CMLL commented Sep 6, 2018

Sadly no. It's been happening with all my files, and I haven't been able to determine a pattern. It's happening on a work project with a pretty large codebase, both in loc and in external dependencies.

@MikhailArkhipov
Copy link

MikhailArkhipov commented Sep 17, 2018

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

@CMLL - Does it throw if you choose Python 3?

@MikhailArkhipov
Copy link

@lock lock bot locked as resolved and limited conversation to collaborators Oct 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

3 participants