Skip to content

Commit

Permalink
Update PythonDataProvider.cs
Browse files Browse the repository at this point in the history
Add .DefaultIfEmpty to stop MaxBy blowing up in absence of Python
  • Loading branch information
jas88 committed Aug 11, 2023
1 parent 8f1fc2d commit e9b06fc
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit e9b06fc

Please sign in to comment.