From f7b9ecdb410e73d2260cdec79dde20329aad4956 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Tue, 3 Jan 2017 15:26:06 -0800 Subject: [PATCH] Fixes #2010 Interpreter link crashes when path variable not set Checks path variable before adding a variable with no name into the environment. --- .../InterpreterListToolWindow.cs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Python/Product/PythonTools/PythonTools/InterpreterList/InterpreterListToolWindow.cs b/Python/Product/PythonTools/PythonTools/InterpreterList/InterpreterListToolWindow.cs index c250be0d09..0e893ad978 100644 --- a/Python/Product/PythonTools/PythonTools/InterpreterList/InterpreterListToolWindow.cs +++ b/Python/Product/PythonTools/PythonTools/InterpreterList/InterpreterListToolWindow.cs @@ -284,16 +284,18 @@ private void StartInterpreter_Executed(object sender, ExecutedRoutedEventArgs e) factory.Configuration.WindowsInterpreterPath; psi.WorkingDirectory = factory.Configuration.PrefixPath; - var provider = _service.KnownProviders.OfType().FirstOrDefault(); - var vsProject = provider == null ? - null : - provider.GetProject(factory); - var project = vsProject == null ? null : vsProject.GetPythonProject(); - if (project != null) { - psi.EnvironmentVariables[factory.Configuration.PathEnvironmentVariable] = - string.Join(";", project.GetSearchPaths()); - } else { - psi.EnvironmentVariables[factory.Configuration.PathEnvironmentVariable] = string.Empty; + var pathVar = factory.Configuration.PathEnvironmentVariable; + if (!string.IsNullOrEmpty(pathVar)) { + var provider = _service.KnownProviders.OfType().FirstOrDefault(); + var vsProject = provider == null ? + null : + provider.GetProject(factory); + var project = vsProject == null ? null : vsProject.GetPythonProject(); + if (project != null) { + psi.EnvironmentVariables[pathVar] = string.Join(";", project.GetSearchPaths()); + } else { + psi.EnvironmentVariables[pathVar] = string.Empty; + } } Process.Start(psi);