Skip to content

Commit

Permalink
Check if file exists instead of launching it (#15726)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored and karthiknadig committed Mar 23, 2021
1 parent 236a712 commit 9718b72
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
1 change: 1 addition & 0 deletions news/2 Fixes/15725.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Check if Python executable file exists instead of launching the Python process.
11 changes: 2 additions & 9 deletions src/client/common/configSettings.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

// eslint-disable-next-line camelcase
import * as child_process from 'child_process';
import * as path from 'path';
import * as fs from 'fs';
import {
ConfigurationChangeEvent,
ConfigurationTarget,
Expand All @@ -27,7 +27,6 @@ import { DEFAULT_INTERPRETER_SETTING, isTestExecution } from './constants';
import { DeprecatePythonPath } from './experiments/groups';
import { ExtensionChannels } from './insidersBuild/types';
import { IS_WINDOWS } from './platform/constants';
import * as internalPython from './process/internal/python';
import {
IAnalysisSettings,
IAutoCompleteSettings,
Expand Down Expand Up @@ -766,13 +765,7 @@ function getPythonExecutable(pythonPath: string): string {
}

function isValidPythonPath(pythonPath: string): boolean {
const [args, parse] = internalPython.isValid();
try {
const output = child_process.execFileSync(pythonPath, args, { encoding: 'utf8' });
return parse(output);
} catch (ex) {
return false;
}
return fs.existsSync(pythonPath);
}

function convertSettingTypeToLogLevel(setting: LoggingLevelSettingType | undefined): LogLevel | 'off' {
Expand Down

0 comments on commit 9718b72

Please sign in to comment.