Fix issues when running without debugging and debugged code terminates#249
Fix issues when running without debugging and debugged code terminates#249DonJayamanne merged 27 commits intomicrosoft:masterfrom
Conversation
Archive of 0.7.0
* 'master' of https://github.com/Microsoft/vscode-python: Fixes #56 list all environments (#219) Fixes #57 Disable activation on debugging (#220) Fixes #26 Do not run linters when linters are disabled (#222)
brettcannon
left a comment
There was a problem hiding this comment.
You probably want to read https://www.python.org/dev/peps/pep-0008/ 😉
| @@ -0,0 +1,150 @@ | |||
| # Copyright (c) Microsoft Corporation. All rights reserved. | |||
| # Licensed under the MIT License. | |||
|
|
|||
There was a problem hiding this comment.
"""Run a block of code or Python file."""|
|
||
| import sys | ||
| import os | ||
| from os import path |
| import visualstudio_py_util as _vspu | ||
| except: | ||
| traceback.print_exc() | ||
| print('''Internal error detected. Please copy the above traceback and report at |
| LOAD = _vspu.to_bytes('LOAD') | ||
|
|
||
| def launch(): | ||
| # Arguments are: |
| # 6. Startup script name. | ||
| # 7. Script arguments. | ||
|
|
||
| # change to directory we expected to start from. |
There was a problem hiding this comment.
"Change" (didn't capitalize the comments).
| return [this.args.program].concat(programArgs); | ||
| protected getLauncherFilePath(): string { | ||
| const currentFileName = module.filename; | ||
| const ptVSToolsPath = path.join(path.dirname(currentFileName), '..', '..', '..', '..', 'pythonFiles', 'PythonTools'); |
There was a problem hiding this comment.
Is there no better way to get to the extension's directory than manually walking backwards?
There was a problem hiding this comment.
No, the extension directory is exposed to the extension, but the debugger is launched in a separate process and we don't have access to the same information that the extension has.
| sys.stderr.write(out) | ||
| sys.stderr.flush() | ||
|
|
||
| def is_same_py_file(file1, file2): |
There was a problem hiding this comment.
file_1, file_2 or something as I barely noticed the two different variable names below with the numbers so close to the text.
| // tslint:disable-next-line:member-ordering | ||
| protected handleProcessOutput(proc: ChildProcess, failedToLaunch: (error: Error | string | Buffer) => void) { | ||
| proc.on('error', error => { | ||
| // TODO: This condition makes no sense (refactor) |
There was a problem hiding this comment.
How bad would it be to fix this now since we all know TODOs never get done. 😉
src/client/debugger/Main.ts
Outdated
| } | ||
| // If launching the integrated terminal is not supported, then defer to external terminal | ||
| // If launching the integrated terminal is not supported, then defer to external terminal | ||
| // that will be displayed by our own code |
src/client/debugger/Main.ts
Outdated
| } | ||
| else { | ||
| this.pythonProcess.SendResumeThread(pyThread.Id); | ||
| if (this.launchArgs.noDebug !== true) { |
There was a problem hiding this comment.
Wouldn't this be !this.launchArgs.noDebug, or does this have to do with null/undefined? Same with the explicit comparisons against boolean values below.
|
@brettcannon all fixed. |
|
@brettcannon , I came across a bug when running on Mac OS (I've fixed the issue with 09b3359 and 9616eef, its the last two commit in this PR) and also filed an issue in the vscode repo. |
|
@brettcannon all comments have been resolved. |
brettcannon
left a comment
There was a problem hiding this comment.
Minor refactoring to do, but I trust you to do it without me blocking you on another round of review.
| 4. Debug options (not used). | ||
| 5. '-m' or '-c' to override the default run-as mode. [optional]. | ||
| 6. Startup script name. | ||
| 7. Script arguments |
There was a problem hiding this comment.
Either add a . or drop them all from the list.
| LOAD = _vspu.to_bytes('LOAD') | ||
|
|
||
| def launch(): | ||
| """Arguments are: |
There was a problem hiding this comment.
Add a one-sentence explanation of what this function does.
| OUTP = _vspu.to_bytes('OUTP') | ||
| LOAD = _vspu.to_bytes('LOAD') | ||
|
|
||
| def launch(): |
There was a problem hiding this comment.
Maybe rename to parse_argv() that teases out the details and then drop the call to run()? Then in the __name__ == '__main__' can call parse_argv() and then call run()?
There was a problem hiding this comment.
Totally agreed, that's cleaner (SOC)
Uh oh!
There was an error while loading. Please reload this page.