Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/18285.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix for UriError when using python.interpreterPath command in tasks.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ export class InterpreterPathCommand implements IExtensionSingleActivationService
// If `launch.json` is launching this command, `args.workspaceFolder` carries the workspaceFolder
// If `tasks.json` is launching this command, `args[1]` carries the workspaceFolder
const workspaceFolder = 'workspaceFolder' in args ? args.workspaceFolder : args[1] ? args[1] : undefined;
return this.configurationService.getSettings(workspaceFolder ? Uri.parse(workspaceFolder) : undefined)
.pythonPath;
let workspaceFolderUri;
try {
workspaceFolderUri = workspaceFolder ? Uri.parse(workspaceFolder) : undefined;
} catch (ex) {
workspaceFolderUri = undefined;
}

return this.configurationService.getSettings(workspaceFolderUri).pythonPath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,14 @@ suite('Interpreter Path Command', () => {
const setting = interpreterPathCommand._getSelectedInterpreterPath(args);
expect(setting).to.equal('settingValue');
});

test('If `args[1]` is not a valid uri', async () => {
const args = ['command', '${input:some_input}'];
when(configService.getSettings(anything())).thenCall((arg) => {
assert.deepEqual(arg, undefined);
return { pythonPath: 'settingValue' } as any;
});
const setting = interpreterPathCommand._getSelectedInterpreterPath(args);
expect(setting).to.equal('settingValue');
});
});