Skip to content

Commit 8ea7bd4

Browse files
authored
Check output of print function to validate python (#2645)
1 parent e5800c1 commit 8ea7bd4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/client/debugger/mainV2.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ export class PythonDebugger extends DebugSession {
127127
const pythonPath = typeof args.pythonPath === 'string' && args.pythonPath.length > 0 ? args.pythonPath : 'python';
128128
const processFactory = this.serviceContainer.get<IProcessServiceFactory>(IProcessServiceFactory);
129129
const processService = await processFactory.create();
130-
const valid = await processService.exec(pythonPath, ['--version'])
131-
.then(output => output.stdout.trim().length > 0)
130+
const valid = await processService.exec(pythonPath, ['-c', 'print("1")'])
131+
.then(output => output.stdout.trim() === '1' || (output.stderr || '').trim() === '1')
132132
.catch(() => false);
133133
if (!valid) {
134134
this.sendErrorResponse(response, { format: InvalidPythonPathInDebuggerMessage, id: 2 }, undefined, undefined, ErrorDestination.User);

0 commit comments

Comments
 (0)