Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1565, #1994, #2005 Auto-detect crashes with Python 3.6 64-bit #2007

Merged
merged 1 commit into from
Jan 3, 2017
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
11 changes: 10 additions & 1 deletion Python/Product/EnvironmentsList/ConfigurationExtension.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,16 @@ private async Task<ConfigurationValues> AutoDetectAsync(ConfigurationValues view
)) {
var exitCode = await output;
if (exitCode == 0) {
view.VersionName = output.StandardOutputLines.FirstOrDefault() ?? view.VersionName;
var vn = output.StandardOutputLines.FirstOrDefault() ?? view.VersionName;
if (ConfigurationEnvironmentView.VersionNames.Contains(vn)) {
view.VersionName = vn;
} else if (vn.CompareTo(ConfigurationEnvironmentView.VersionNames.Last()) > 0) {
view.VersionName = ConfigurationEnvironmentView.VersionNames.Last();
} else if (vn.CompareTo(ConfigurationEnvironmentView.VersionNames.First()) < 0) {
view.VersionName = ConfigurationEnvironmentView.VersionNames.First();
} else {
view.VersionName = "2.7";
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using Microsoft.PythonTools.Parsing;
using Microsoft.VisualStudio.Settings;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudioTools;
Expand Down Expand Up @@ -62,19 +63,34 @@ private PythonInterpreterFactoryWithDatabase LoadUserDefinedInterpreter(Settings
var pathEnvVar = store.GetString(collection, PathEnvVarKey, string.Empty);
var description = store.GetString(collection, DescriptionKey, string.Empty);

return InterpreterFactoryCreator.CreateInterpreterFactory(
new InterpreterFactoryCreationOptions {
LanguageVersionString = version,
Id = id,
Description = description,
InterpreterPath = path,
WindowInterpreterPath = winPath,
LibraryPath = libPath,
PathEnvironmentVariableName = pathEnvVar,
ArchitectureString = arch,
WatchLibraryForNewModules = true
var opts = new InterpreterFactoryCreationOptions {
Id = id,
Description = description,
InterpreterPath = path,
WindowInterpreterPath = winPath,
LibraryPath = libPath,
PathEnvironmentVariableName = pathEnvVar,
ArchitectureString = arch,
WatchLibraryForNewModules = true
};

// https://github.com/Microsoft/PTVS/issues/1994
// Loading an unsupported version from the registry would crash.
// Now we reset the version so that the environment still appears
// and can be modified.
Version ver;
try {
if (Version.TryParse(version, out ver) && ver.ToLanguageVersion().ToVersion() == ver) {
opts.LanguageVersion = ver;
}
);
} catch (InvalidOperationException) {
}

try {
return InterpreterFactoryCreator.CreateInterpreterFactory(opts);
} catch (ArgumentException) {
return null;
}
}
return null;
}
Expand Down