@@ -12,7 +12,7 @@ import { EXTENSION_ROOT_DIR } from '../../../../constants';
12
12
import { createDeferred , createDeferredFrom } from '../../../../common/utils/async' ;
13
13
import { DisposableBase , DisposableStore } from '../../../../common/utils/resourceLifecycle' ;
14
14
import { noop } from '../../../../common/utils/misc' ;
15
- import { getConfiguration , getWorkspaceFolderPaths } from '../../../../common/vscodeApis/workspaceApis' ;
15
+ import { getConfiguration , getWorkspaceFolderPaths , isTrusted } from '../../../../common/vscodeApis/workspaceApis' ;
16
16
import { CONDAPATH_SETTING_KEY } from '../../../common/environmentManagers/conda' ;
17
17
import { VENVFOLDERS_SETTING_KEY , VENVPATH_SETTING_KEY } from '../lowLevel/customVirtualEnvLocator' ;
18
18
import { getUserHomeDir } from '../../../../common/utils/platform' ;
@@ -22,6 +22,7 @@ import { NativePythonEnvironmentKind } from './nativePythonUtils';
22
22
import type { IExtensionContext } from '../../../../common/types' ;
23
23
import { StopWatch } from '../../../../common/utils/stopWatch' ;
24
24
import { untildify } from '../../../../common/helpers' ;
25
+ import { traceError } from '../../../../logging' ;
25
26
26
27
const PYTHON_ENV_TOOLS_PATH = isWindows ( )
27
28
? path . join ( EXTENSION_ROOT_DIR , 'python-env-tools' , 'bin' , 'pet.exe' )
@@ -440,6 +441,25 @@ function getPythonSettingAndUntildify<T>(name: string, scope?: Uri): T | undefin
440
441
441
442
let _finder : NativePythonFinder | undefined ;
442
443
export function getNativePythonFinder ( context ?: IExtensionContext ) : NativePythonFinder {
444
+ if ( ! isTrusted ( ) ) {
445
+ return {
446
+ async * refresh ( ) {
447
+ traceError ( 'Python discovery not supported in untrusted workspace' ) ;
448
+ yield * [ ] ;
449
+ } ,
450
+ async resolve ( ) {
451
+ traceError ( 'Python discovery not supported in untrusted workspace' ) ;
452
+ return { } ;
453
+ } ,
454
+ async getCondaInfo ( ) {
455
+ traceError ( 'Python discovery not supported in untrusted workspace' ) ;
456
+ return ( { } as unknown ) as NativeCondaInfo ;
457
+ } ,
458
+ dispose ( ) {
459
+ // do nothing
460
+ } ,
461
+ } ;
462
+ }
443
463
if ( ! _finder ) {
444
464
const cacheDirectory = context ? getCacheDirectory ( context ) : undefined ;
445
465
_finder = new NativePythonFinderImpl ( cacheDirectory ) ;
0 commit comments