From e9b06fc7001e5dd447f646c486265d855bda2b2a Mon Sep 17 00:00:00 2001 From: jas88 Date: Fri, 11 Aug 2023 17:10:09 -0500 Subject: [PATCH] Update PythonDataProvider.cs Add .DefaultIfEmpty to stop MaxBy blowing up in absence of Python --- .../DataProvider/PythonDataProvider.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Python/LoadModules.Extensions.Python/DataProvider/PythonDataProvider.cs b/Python/LoadModules.Extensions.Python/DataProvider/PythonDataProvider.cs index 7a5356b..87dfd7f 100644 --- a/Python/LoadModules.Extensions.Python/DataProvider/PythonDataProvider.cs +++ b/Python/LoadModules.Extensions.Python/DataProvider/PythonDataProvider.cs @@ -311,7 +311,8 @@ private static (decimal minor, string fullVersion, string path) GetPython(char m using var user = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Python\\PythonCore"); using var machine32 = Registry.LocalMachine.OpenSubKey("SOFTWARE\\WOW6432Node\\Python\\PythonCore"); using var user32 = Registry.CurrentUser.OpenSubKey("SOFTWARE\\WOW6432Node\\Python\\PythonCore"); - var candidate = GetPythonVersions(machine,major).Union(GetPythonVersions(user,major)).MaxBy(static v=>v.minor); + var candidate = GetPythonVersions(machine, major).Union(GetPythonVersions(user, major)).DefaultIfEmpty() + .MaxBy(static v => v.minor); return candidate; }