microsoft / PTVS

Python Tools for Visual Studio
https://aka.ms/PTVS
Apache License 2.0
2.53k stars 676 forks source link

crashing upon modules missing on import #3408

Closed sma202 closed 5 years ago

sma202 commented 6 years ago

VS crashes if I have a missing module that's not installed on the python environment for my project.

-The debugger stops at the import that is missing. -Then I get a progress bar that says "debugger operation in progress". -I click cancel and "Visual Studio has stopped working".

I also get a ton of messages on the output screen before the program loads that weren't there before in PTVS:

"Standard library module invoked user code during import; breakpoints disabled for invoked code."

The latest incarnation of Python in VS has become so unstable that hardly work can be done in this IDE.

huguesv commented 6 years ago

Would you have a minimal repro that you could share with us? It could be a timing issue and/or something special about your local variables at the time it breaks.

As for the messages, they were added in https://github.com/Microsoft/PTVS/commit/feefb131801ad6f465dd107be0d74e9a73043b1f#diff-1c2be635c362d7c7db19558ed2d578df maybe @int19h can explain the intention there.

sma202 commented 6 years ago

The only way to stop this from recurring is to uncheck Exception Settings->Python Exceptions->ImportError.

huguesv commented 6 years ago

So this happens for you even with the simplest of programs, like this 1-line app?

import module_that_doesnt_exist
sma202 commented 6 years ago

Yes. However it occurs on more complicated projects with 50+ files where I am importing custom modules as well as python modules.

huguesv commented 6 years ago

@sma202 we have a fix checked in that should suppress most/all of the warning messages in the output window. It will be available first in 15.6 Preview 3.

If you'd like to try it right now, you should be able to overwrite your copy of debugger.py with the latest version at https://github.com/Microsoft/PTVS/blob/master/Python/Product/PythonTools/ptvsd/debugger.py

(search for debugger.py under your microsoft visual studio install directory)

It's possible that these warnings may have been the cause of the "debugger operation in progress" or made it much worse.