X Tutup
Skip to content

Commit 02cd234

Browse files
committed
revert to C# 7.3
1 parent 0d941c5 commit 02cd234

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

src/embed_tests/Codecs.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,28 +89,32 @@ public void ExceptionEncoded() {
8989
PyObjectConversions.RegisterEncoder(new ValueErrorCodec());
9090
void CallMe() => throw new ValueErrorWrapper(TestExceptionMessage);
9191
var callMeAction = new Action(CallMe);
92-
using var _ = Py.GIL();
93-
using var scope = Py.CreateScope();
94-
scope.Exec(@"
92+
using (var _ = Py.GIL())
93+
using (var scope = Py.CreateScope())
94+
{
95+
scope.Exec(@"
9596
def call(func):
9697
try:
9798
func()
9899
except ValueError as e:
99100
return str(e)
100101
");
101-
var callFunc = scope.Get("call");
102-
string message = callFunc.Invoke(callMeAction.ToPython()).As<string>();
103-
Assert.AreEqual(TestExceptionMessage, message);
102+
var callFunc = scope.Get("call");
103+
string message = callFunc.Invoke(callMeAction.ToPython()).As<string>();
104+
Assert.AreEqual(TestExceptionMessage, message);
105+
}
104106
}
105107

106108
[Test]
107109
public void ExceptionDecoded() {
108110
PyObjectConversions.RegisterDecoder(new ValueErrorCodec());
109-
using var _ = Py.GIL();
110-
using var scope = Py.CreateScope();
111-
var error = Assert.Throws<ValueErrorWrapper>(() => PythonEngine.Exec(
112-
$"raise ValueError('{TestExceptionMessage}')"));
113-
Assert.AreEqual(TestExceptionMessage, error.Message);
111+
using (var _ = Py.GIL())
112+
using (var scope = Py.CreateScope())
113+
{
114+
var error = Assert.Throws<ValueErrorWrapper>(()
115+
=> PythonEngine.Exec($"raise ValueError('{TestExceptionMessage}')"));
116+
Assert.AreEqual(TestExceptionMessage, error.Message);
117+
}
114118
}
115119

116120
class ValueErrorWrapper : Exception {

src/embed_tests/Python.EmbeddingTest.15.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
2424
<PythonBuildDir Condition="'$(TargetFramework)'=='net40' AND '$(PythonBuildDir)' == ''">$(SolutionDir)\bin\</PythonBuildDir>
2525
<PublishDir Condition="'$(TargetFramework)'!='net40'">$(OutputPath)\$(TargetFramework)_publish</PublishDir>
26-
<LangVersion>8.0</LangVersion>
26+
<LangVersion>7.3</LangVersion>
2727
<ErrorReport>prompt</ErrorReport>
2828
<CustomDefineConstants Condition="'$(CustomDefineConstants)' == ''">$(PYTHONNET_DEFINE_CONSTANTS)</CustomDefineConstants>
2929
<BaseDefineConstants>XPLAT</BaseDefineConstants>

0 commit comments

Comments
 (0)
X Tutup