Skip to content

Commit 39690f8

Browse files
author
Mikhail Arkhipov
committed
Merge branch 'master' of https://github.com/microsoft/python-language-server into stubnav
2 parents 1f6af48 + d480cd1 commit 39690f8

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

CONTRIBUTING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
### Prerequisites
66

7-
1. .NET Core 2.2 SDK
7+
1. .NET Core 3.1 SDK
88
- [Windows](https://www.microsoft.com/net/learn/get-started/windows)
99
- [Mac OS](https://www.microsoft.com/net/learn/get-started/macos)
1010
- [Linux](https://www.microsoft.com/net/learn/get-started/linux/rhel)
1111
2. C# Extension to [VS Code](https://code.visualstudio.com) (all platforms)
1212
3. Python 2.7
13-
4. Python 3.6
13+
4. Python 3.6+
1414

15-
*Alternative:* [Visual Studio 2017 or 2019](https://www.visualstudio.com/downloads/) (Windows only) with .NET Core and C# Workloads. Community Edition is free and is fully functional.
15+
*Alternative:* [Visual Studio 2019](https://www.visualstudio.com/downloads/) (Windows only) with .NET Core and C# Workloads. Community Edition is free and is fully functional.
1616

1717
### Setup
1818

@@ -54,7 +54,7 @@ On Windows you can also attach from Visual Studio (Debug | Attach To Process).
5454
### Unit Tests
5555
To run unit tests, do one of the following:
5656
- Run the Unit Tests in the [VS Code Python Extension](https://github.com/Microsoft/vscode-python) project via *Launch Language Server Tests*.
57-
- On Windows: open the `PLS.sln` solution in Visual Studio 2017 or 2019 and run tests from the Test Explorer.
57+
- On Windows: open the `PLS.sln` solution in Visual Studio 2019 and run tests from the Test Explorer.
5858
- Run `dotnet test` from Terminal in the `src` directory, or in a specific directory like `src/Analysis/Ast/Test` to test a specific suite.
5959
- Install C# extension and .NET Core Test Explorer for VS Code, open src folder in VS Code and run tests.
6060

src/Analysis/Ast/Impl/Analyzer/Evaluation/ExpressionEval.Scopes.cs

+12-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
using Microsoft.Python.Analysis.Values;
2222
using Microsoft.Python.Core;
2323
using Microsoft.Python.Core.Disposables;
24-
using Microsoft.Python.Core.Text;
2524
using Microsoft.Python.Parsing.Ast;
2625

2726
namespace Microsoft.Python.Analysis.Analyzer.Evaluation {
@@ -55,12 +54,12 @@ public void DeclareVariable(string name, IMember value, VariableSource source, L
5554
if (member != null && !overwrite) {
5655
return;
5756
}
58-
57+
5958
if (source == VariableSource.Import && value is IVariable v) {
6059
CurrentScope.LinkVariable(name, v, location);
6160
return;
6261
}
63-
62+
6463
if (member != null) {
6564
if (!value.IsUnknown()) {
6665
CurrentScope.DeclareVariable(name, value, source, location);
@@ -193,10 +192,17 @@ public void Dispose() {
193192
// them better.
194193
// TODO: figure out threading/locking for the Open/Close pairs.
195194
// Debug.Assert(_eval._openScopes.Count > 0, "Attempt to close global scope");
196-
if (_eval._openScopes.Count > 0) {
197-
_eval._openScopes.Pop();
195+
try {
196+
if (_eval._openScopes.Count > 0) {
197+
_eval._openScopes.Pop();
198+
}
199+
_eval.CurrentScope = _eval._openScopes.Count == 0 ? _eval.GlobalScope : _eval._openScopes.Peek();
200+
} catch (InvalidOperationException) {
201+
// Per comment above this can happen occasionally.
202+
// The catch is tactical fix to prevent crashes since complete handling of open/close
203+
// in threaded cases would be much larger change.
204+
_eval.Log?.Log(TraceEventType.Verbose, "Error: Mismatched open/close in scope tracker - scope stack is empty on Dispose()");
198205
}
199-
_eval.CurrentScope = _eval._openScopes.Count == 0 ? _eval.GlobalScope : _eval._openScopes.Peek();
200206
}
201207
}
202208
}

0 commit comments

Comments
 (0)