@@ -7,6 +7,7 @@ import { IServiceContainer } from '../../ioc/types';
77import { EXTENSION_ROOT_DIR } from '../constants' ;
88import { ErrorUtils } from '../errors/errorUtils' ;
99import { ModuleNotInstalledError } from '../errors/moduleNotInstalledError' ;
10+ import { traceError } from '../logger' ;
1011import { IFileSystem } from '../platform/types' ;
1112import { Architecture } from '../utils/platform' ;
1213import { ExecutionResult , InterpreterInfomation , IProcessService , IPythonExecutionService , ObservableExecutionResult , PythonVersionInfo , SpawnOptions } from './types' ;
@@ -33,7 +34,13 @@ export class PythonExecutionService implements IPythonExecutionService {
3334 . then ( output => output . stdout . trim ( ) )
3435 ] ) ;
3536
36- const json = JSON . parse ( jsonValue ) as { versionInfo : PythonVersionInfo ; sysPrefix : string ; sysVersion : string ; is64Bit : boolean } ;
37+ let json : { versionInfo : PythonVersionInfo ; sysPrefix : string ; sysVersion : string ; is64Bit : boolean } ;
38+ try {
39+ json = JSON . parse ( jsonValue ) ;
40+ } catch ( ex ) {
41+ traceError ( `Failed to parse interpreter information for '${ this . pythonPath } ' with JSON ${ jsonValue } ` , ex ) ;
42+ return ;
43+ }
3744 const version_info = json . versionInfo ;
3845 // Exclude PII from `version_info` to ensure we don't send this up via telemetry.
3946 for ( let index = 0 ; index < 3 ; index += 1 ) {
@@ -53,7 +60,7 @@ export class PythonExecutionService implements IPythonExecutionService {
5360 sysPrefix : json . sysPrefix
5461 } ;
5562 } catch ( ex ) {
56- console . error ( `Failed to get interpreter information for '${ this . pythonPath } '` , ex ) ;
63+ traceError ( `Failed to get interpreter information for '${ this . pythonPath } '` , ex ) ;
5764 }
5865 }
5966 public async getExecutablePath ( ) : Promise < string > {
0 commit comments