@@ -7,6 +7,7 @@ import { IServiceContainer } from '../../ioc/types';
7
7
import { EXTENSION_ROOT_DIR } from '../constants' ;
8
8
import { ErrorUtils } from '../errors/errorUtils' ;
9
9
import { ModuleNotInstalledError } from '../errors/moduleNotInstalledError' ;
10
+ import { traceError } from '../logger' ;
10
11
import { IFileSystem } from '../platform/types' ;
11
12
import { Architecture } from '../utils/platform' ;
12
13
import { ExecutionResult , InterpreterInfomation , IProcessService , IPythonExecutionService , ObservableExecutionResult , PythonVersionInfo , SpawnOptions } from './types' ;
@@ -33,7 +34,13 @@ export class PythonExecutionService implements IPythonExecutionService {
33
34
. then ( output => output . stdout . trim ( ) )
34
35
] ) ;
35
36
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
+ }
37
44
const version_info = json . versionInfo ;
38
45
// Exclude PII from `version_info` to ensure we don't send this up via telemetry.
39
46
for ( let index = 0 ; index < 3 ; index += 1 ) {
@@ -53,7 +60,7 @@ export class PythonExecutionService implements IPythonExecutionService {
53
60
sysPrefix : json . sysPrefix
54
61
} ;
55
62
} 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 ) ;
57
64
}
58
65
}
59
66
public async getExecutablePath ( ) : Promise < string > {
0 commit comments