From 056c480aa36710251e90f7377c4d6f2ae7cdb3f2 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 20 Sep 2018 14:54:24 -0700 Subject: [PATCH] Check output of print function to validate python --- src/client/debugger/mainV2.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/debugger/mainV2.ts b/src/client/debugger/mainV2.ts index 9c5df1076ec4..65e3370b2d3f 100644 --- a/src/client/debugger/mainV2.ts +++ b/src/client/debugger/mainV2.ts @@ -127,8 +127,8 @@ export class PythonDebugger extends DebugSession { const pythonPath = typeof args.pythonPath === 'string' && args.pythonPath.length > 0 ? args.pythonPath : 'python'; const processFactory = this.serviceContainer.get(IProcessServiceFactory); const processService = await processFactory.create(); - const valid = await processService.exec(pythonPath, ['--version']) - .then(output => output.stdout.trim().length > 0) + const valid = await processService.exec(pythonPath, ['-c', 'print("1")']) + .then(output => output.stdout.trim() === '1' || (output.stderr || '').trim() === '1') .catch(() => false); if (!valid) { this.sendErrorResponse(response, { format: InvalidPythonPathInDebuggerMessage, id: 2 }, undefined, undefined, ErrorDestination.User);