From fde203ee1cbfd8c7e65ac303e979e94c60d77072 Mon Sep 17 00:00:00 2001 From: Karthik Nadig Date: Mon, 9 Dec 2024 14:48:08 +0530 Subject: [PATCH] Revert "Fix) Prevent keyboard interrupt for Python3.13 REPL non-Windows " (#24559) Reverts microsoft/vscode-python#24555 --- src/client/common/terminal/service.ts | 14 ++------------ src/test/common/terminals/service.unit.test.ts | 11 +---------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/client/common/terminal/service.ts b/src/client/common/terminal/service.ts index 64892045b391..e37539f1bc7c 100644 --- a/src/client/common/terminal/service.ts +++ b/src/client/common/terminal/service.ts @@ -22,7 +22,6 @@ import { import { traceVerbose } from '../../logging'; import { getConfiguration } from '../vscodeApis/workspaceApis'; import { isWindows } from '../utils/platform'; -import { getActiveInterpreter } from '../../repl/replUtils'; @injectable() export class TerminalService implements ITerminalService, Disposable { @@ -103,19 +102,10 @@ export class TerminalService implements ITerminalService, Disposable { }); await promise; } + const config = getConfiguration('python'); const pythonrcSetting = config.get('terminal.shellIntegration.enabled'); - - let isPython313 = false; - if (this.options && this.options.resource) { - const pythonVersion = await getActiveInterpreter( - this.options.resource, - this.serviceContainer.get(IInterpreterService), - ); - pythonVersion?.sysVersion?.startsWith('3.13'); - } - - if (isPythonShell && (!pythonrcSetting || isWindows() || isPython313)) { + if ((isPythonShell && !pythonrcSetting) || (isPythonShell && isWindows())) { // If user has explicitly disabled SI for Python, use sendText for inside Terminal REPL. terminal.sendText(commandLine); return undefined; diff --git a/src/test/common/terminals/service.unit.test.ts b/src/test/common/terminals/service.unit.test.ts index d46d17a01ded..147803a72598 100644 --- a/src/test/common/terminals/service.unit.test.ts +++ b/src/test/common/terminals/service.unit.test.ts @@ -25,8 +25,6 @@ import { ITerminalAutoActivation } from '../../../client/terminals/types'; import { createPythonInterpreter } from '../../utils/interpreters'; import * as workspaceApis from '../../../client/common/vscodeApis/workspaceApis'; import * as platform from '../../../client/common/utils/platform'; -import { IInterpreterService } from '../../../client/interpreter/contracts'; -import { PythonEnvironment } from '../../../client/pythonEnvironments/info'; suite('Terminal Service', () => { let service: TerminalService; @@ -46,7 +44,6 @@ suite('Terminal Service', () => { let pythonConfig: TypeMoq.IMock; let editorConfig: TypeMoq.IMock; let isWindowsStub: sinon.SinonStub; - let interpreterService: TypeMoq.IMock; setup(() => { terminal = TypeMoq.Mock.ofType(); @@ -90,10 +87,6 @@ suite('Terminal Service', () => { disposables = []; mockServiceContainer = TypeMoq.Mock.ofType(); - interpreterService = TypeMoq.Mock.ofType(); - interpreterService - .setup((i) => i.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve(({ path: 'ps' } as unknown) as PythonEnvironment)); mockServiceContainer.setup((c) => c.get(ITerminalManager)).returns(() => terminalManager.object); mockServiceContainer.setup((c) => c.get(ITerminalHelper)).returns(() => terminalHelper.object); @@ -102,8 +95,6 @@ suite('Terminal Service', () => { mockServiceContainer.setup((c) => c.get(IWorkspaceService)).returns(() => workspaceService.object); mockServiceContainer.setup((c) => c.get(ITerminalActivator)).returns(() => terminalActivator.object); mockServiceContainer.setup((c) => c.get(ITerminalAutoActivation)).returns(() => terminalAutoActivator.object); - mockServiceContainer.setup((c) => c.get(IInterpreterService)).returns(() => interpreterService.object); - getConfigurationStub = sinon.stub(workspaceApis, 'getConfiguration'); isWindowsStub = sinon.stub(platform, 'isWindows'); pythonConfig = TypeMoq.Mock.ofType(); @@ -243,7 +234,7 @@ suite('Terminal Service', () => { terminal.verify((t) => t.sendText(TypeMoq.It.isValue(textToSend)), TypeMoq.Times.exactly(1)); }); - test('Ensure sendText is NOT called when Python shell integration and terminal shell integration are both enabled - Mac, Linux - !Python3.13', async () => { + test('Ensure sendText is NOT called when Python shell integration and terminal shell integration are both enabled - Mac, Linux', async () => { isWindowsStub.returns(false); pythonConfig .setup((p) => p.get('terminal.shellIntegration.enabled'))