Skip to content

Commit

Permalink
Merge pull request #1127 from zooba/issue-1097
Browse files Browse the repository at this point in the history
Fixes #1097 Cannot add existing virtualenv when home has no trailing backslash
  • Loading branch information
Dino Viehland committed Mar 2, 2016
2 parents 5475938 + f593217 commit c41fcbf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Python/Product/VSInterpreters/DerivedInterpreterFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ InterpreterFactoryCreationOptions options
string libPath,
IInterpreterOptionsService service
) {
string basePath = GetOrigPrefixPath(prefixPath, libPath);
string basePath = CommonUtils.TrimEndSeparator(GetOrigPrefixPath(prefixPath, libPath));

if (Directory.Exists(basePath)) {
return service.Interpreters.FirstOrDefault(interp =>
CommonUtils.IsSamePath(interp.Configuration.PrefixPath, basePath)
CommonUtils.IsSamePath(CommonUtils.TrimEndSeparator(interp.Configuration.PrefixPath), basePath)
);
}
return null;
Expand All @@ -298,7 +298,7 @@ IInterpreterOptionsService service
.Where(m => m != null && m.Success)
.Select(m => m.Groups["path"])
.Where(g => g != null && g.Success)
.Select(g => g.Value)
.Select(g => g.Value.Trim())
.FirstOrDefault(CommonUtils.IsValidPath);
} catch (IOException) {
} catch (UnauthorizedAccessException) {
Expand All @@ -318,7 +318,7 @@ IInterpreterOptionsService service
if (basePath == null && File.Exists(prefixFile)) {
try {
var lines = File.ReadAllLines(prefixFile);
basePath = lines.FirstOrDefault(CommonUtils.IsValidPath);
basePath = (lines.FirstOrDefault(CommonUtils.IsValidPath) ?? string.Empty).Trim();
} catch (IOException) {
} catch (UnauthorizedAccessException) {
} catch (System.Security.SecurityException) {
Expand Down

0 comments on commit c41fcbf

Please sign in to comment.