diff --git a/Directory.Build.props b/Directory.Build.props
index 6716f29df..d724e41e7 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -4,7 +4,6 @@
Copyright (c) 2006-2021 The Contributors of the Python.NET Project
pythonnet
Python.NET
- 10.0
false
diff --git a/src/console/Console.csproj b/src/console/Console.csproj
index 5ca5192e3..edd9054ef 100644
--- a/src/console/Console.csproj
+++ b/src/console/Console.csproj
@@ -1,6 +1,6 @@
- net6.0
+ net9.0
Exe
nPython
Python.Runtime
diff --git a/src/embed_tests/Python.EmbeddingTest.csproj b/src/embed_tests/Python.EmbeddingTest.csproj
index 84dcb3fe2..f50311141 100644
--- a/src/embed_tests/Python.EmbeddingTest.csproj
+++ b/src/embed_tests/Python.EmbeddingTest.csproj
@@ -1,7 +1,7 @@
- net6.0
+ net9.0
..\pythonnet.snk
true
diff --git a/src/embed_tests/StateSerialization/MethodSerialization.cs b/src/embed_tests/StateSerialization/MethodSerialization.cs
index 80b7a08ee..21a6cfa52 100644
--- a/src/embed_tests/StateSerialization/MethodSerialization.cs
+++ b/src/embed_tests/StateSerialization/MethodSerialization.cs
@@ -1,4 +1,4 @@
-using System.IO;
+/*using System.IO;
using System.Reflection;
using NUnit.Framework;
@@ -44,3 +44,4 @@ public class MethodTestHost
public MethodTestHost(int _) { }
public void Generic(T item, T[] array, ref T @ref) { }
}
+*/
diff --git a/src/perf_tests/Python.PerformanceTests.csproj b/src/perf_tests/Python.PerformanceTests.csproj
index 7d6192974..540e18b66 100644
--- a/src/perf_tests/Python.PerformanceTests.csproj
+++ b/src/perf_tests/Python.PerformanceTests.csproj
@@ -1,7 +1,7 @@
- net6.0
+ net9.0
false
@@ -13,7 +13,7 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
compile
@@ -25,7 +25,7 @@
-
+
diff --git a/src/python_tests_runner/Python.PythonTestsRunner.csproj b/src/python_tests_runner/Python.PythonTestsRunner.csproj
index 04b8ef252..16e563ff6 100644
--- a/src/python_tests_runner/Python.PythonTestsRunner.csproj
+++ b/src/python_tests_runner/Python.PythonTestsRunner.csproj
@@ -1,7 +1,7 @@
- net6.0
+ net9.0
diff --git a/src/runtime/MethodBinder.cs b/src/runtime/MethodBinder.cs
index 25dd76621..8c8bac65d 100644
--- a/src/runtime/MethodBinder.cs
+++ b/src/runtime/MethodBinder.cs
@@ -793,7 +793,6 @@ internal Binding Bind(BorrowedReference inst, BorrowedReference args, BorrowedRe
static BorrowedReference HandleParamsArray(BorrowedReference args, int arrayStart, int pyArgCount, out NewReference tempObject)
{
- BorrowedReference op;
tempObject = default;
// for a params method, we may have a sequence or single/multiple items
// here we look to see if the item at the paramIndex is there or not
@@ -806,20 +805,19 @@ static BorrowedReference HandleParamsArray(BorrowedReference args, int arrayStar
if (!Runtime.PyString_Check(item) && (Runtime.PySequence_Check(item) || (ManagedType.GetManagedObject(item) as CLRObject)?.inst is IEnumerable))
{
// it's a sequence (and not a string), so we use it as the op
- op = item;
+ return item;
}
else
{
tempObject = Runtime.PyTuple_GetSlice(args, arrayStart, pyArgCount);
- op = tempObject.Borrow();
+ return tempObject.Borrow();
}
}
else
{
tempObject = Runtime.PyTuple_GetSlice(args, arrayStart, pyArgCount);
- op = tempObject.Borrow();
+ return tempObject.Borrow();
}
- return op;
}
///
diff --git a/src/runtime/Native/NewReference.cs b/src/runtime/Native/NewReference.cs
index 00e01d75f..456503b41 100644
--- a/src/runtime/Native/NewReference.cs
+++ b/src/runtime/Native/NewReference.cs
@@ -15,7 +15,7 @@ ref struct NewReference
/// Creates a pointing to the same object
[DebuggerHidden]
- public NewReference(BorrowedReference reference, bool canBeNull = false)
+ public NewReference(scoped BorrowedReference reference, bool canBeNull = false)
{
var address = canBeNull
? reference.DangerousGetAddressOrNull()
@@ -157,15 +157,15 @@ public static bool IsNull(this in NewReference reference)
[Pure]
[DebuggerHidden]
- public static BorrowedReference BorrowNullable(this in NewReference reference)
+ public static BorrowedReference BorrowNullable(this scoped in NewReference reference)
=> new(NewReference.DangerousGetAddressOrNull(reference));
[Pure]
[DebuggerHidden]
- public static BorrowedReference Borrow(this in NewReference reference)
+ public static BorrowedReference Borrow(this scoped in NewReference reference)
=> reference.IsNull() ? throw new NullReferenceException() : reference.BorrowNullable();
[Pure]
[DebuggerHidden]
- public static BorrowedReference BorrowOrThrow(this in NewReference reference)
+ public static BorrowedReference BorrowOrThrow(this scoped in NewReference reference)
=> reference.IsNull() ? throw PythonException.ThrowLastAsClrException() : reference.BorrowNullable();
}
}
diff --git a/src/runtime/Native/StolenReference.cs b/src/runtime/Native/StolenReference.cs
index 49304c1fd..14c3a6995 100644
--- a/src/runtime/Native/StolenReference.cs
+++ b/src/runtime/Native/StolenReference.cs
@@ -28,7 +28,7 @@ public static StolenReference Take(ref IntPtr ptr)
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[DebuggerHidden]
- public static StolenReference TakeNullable(ref IntPtr ptr)
+ public static StolenReference TakeNullable(scoped ref IntPtr ptr)
{
var stolenAddr = ptr;
ptr = IntPtr.Zero;
diff --git a/src/runtime/Properties/AssemblyInfo.cs b/src/runtime/Properties/AssemblyInfo.cs
index 448265145..126b2f62e 100644
--- a/src/runtime/Properties/AssemblyInfo.cs
+++ b/src/runtime/Properties/AssemblyInfo.cs
@@ -4,5 +4,5 @@
[assembly: InternalsVisibleTo("Python.EmbeddingTest, PublicKey=00240000048000009400000006020000002400005253413100040000110000005ffd8f49fb44ab0641b3fd8d55e749f716e6dd901032295db641eb98ee46063cbe0d4a1d121ef0bc2af95f8a7438d7a80a3531316e6b75c2dae92fb05a99f03bf7e0c03980e1c3cfb74ba690aca2f3339ef329313bcc5dccced125a4ffdc4531dcef914602cd5878dc5fbb4d4c73ddfbc133f840231343e013762884d6143189")]
[assembly: InternalsVisibleTo("Python.Test, PublicKey=00240000048000009400000006020000002400005253413100040000110000005ffd8f49fb44ab0641b3fd8d55e749f716e6dd901032295db641eb98ee46063cbe0d4a1d121ef0bc2af95f8a7438d7a80a3531316e6b75c2dae92fb05a99f03bf7e0c03980e1c3cfb74ba690aca2f3339ef329313bcc5dccced125a4ffdc4531dcef914602cd5878dc5fbb4d4c73ddfbc133f840231343e013762884d6143189")]
-[assembly: AssemblyVersion("2.0.41")]
-[assembly: AssemblyFileVersion("2.0.41")]
+[assembly: AssemblyVersion("2.0.42")]
+[assembly: AssemblyFileVersion("2.0.42")]
diff --git a/src/runtime/Python.Runtime.csproj b/src/runtime/Python.Runtime.csproj
index a3fd340be..4ab951154 100644
--- a/src/runtime/Python.Runtime.csproj
+++ b/src/runtime/Python.Runtime.csproj
@@ -1,11 +1,11 @@
- net6.0
+ net9.0
AnyCPU
Python.Runtime
Python.Runtime
QuantConnect.pythonnet
- 2.0.41
+ 2.0.42
false
LICENSE
https://github.com/pythonnet/pythonnet
diff --git a/src/runtime/Runtime.cs b/src/runtime/Runtime.cs
index a4a6acb05..7febdbcb2 100644
--- a/src/runtime/Runtime.cs
+++ b/src/runtime/Runtime.cs
@@ -157,15 +157,8 @@ internal static void Initialize(bool initSigs = false)
// Initialize modules that depend on the runtime class.
AssemblyManager.Initialize();
OperatorMethod.Initialize();
- if (RuntimeData.HasStashData())
- {
- RuntimeData.RestoreRuntimeData();
- }
- else
- {
- PyCLRMetaType = MetaType.Initialize();
- ImportHook.Initialize();
- }
+ PyCLRMetaType = MetaType.Initialize();
+ ImportHook.Initialize();
Exceptions.Initialize();
// Need to add the runtime directory to sys.path so that we
@@ -269,8 +262,6 @@ internal static void Shutdown()
{
// avoid saving dead objects
TryCollectingGarbage(runs: 3);
-
- RuntimeData.Stash();
}
AssemblyManager.Shutdown();
@@ -832,7 +823,7 @@ public static int Py_Main(int argc, string[] argv)
internal static IntPtr Py_GetBuildInfo() => Delegates.Py_GetBuildInfo();
- const PyCompilerFlags Utf8String = PyCompilerFlags.IGNORE_COOKIE | PyCompilerFlags.SOURCE_IS_UTF8;
+ private static readonly PyCompilerFlags Utf8String = PyCompilerFlags.IGNORE_COOKIE | PyCompilerFlags.SOURCE_IS_UTF8;
internal static int PyRun_SimpleString(string code)
{
@@ -1715,7 +1706,7 @@ internal static bool PyType_IsSameAsOrSubtype(BorrowedReference type, BorrowedRe
internal static NewReference PyType_GenericAlloc(BorrowedReference type, nint n) => Delegates.PyType_GenericAlloc(type, n);
internal static IntPtr PyType_GetSlot(BorrowedReference type, TypeSlotID slot) => Delegates.PyType_GetSlot(type, slot);
- internal static NewReference PyType_FromSpecWithBases(in NativeTypeSpec spec, BorrowedReference bases) => Delegates.PyType_FromSpecWithBases(in spec, bases);
+ internal static NewReference PyType_FromSpecWithBases(scoped in NativeTypeSpec spec, BorrowedReference bases) => Delegates.PyType_FromSpecWithBases(in spec, bases);
///
/// Finalize a type object. This should be called on all type objects to finish their initialization. This function is responsible for adding inherited slots from a type�s base class. Return 0 on success, or return -1 and sets an exception on error.
diff --git a/src/runtime/StateSerialization/RuntimeData.cs b/src/runtime/StateSerialization/RuntimeData.cs
index a60796a87..20d9e2e8a 100644
--- a/src/runtime/StateSerialization/RuntimeData.cs
+++ b/src/runtime/StateSerialization/RuntimeData.cs
@@ -1,4 +1,4 @@
-using System;
+/*using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -210,3 +210,4 @@ internal static IFormatter CreateFormatter()
}
}
}
+*/
diff --git a/src/testing/Python.Test.csproj b/src/testing/Python.Test.csproj
index 24a8f72c4..7f688f0ba 100644
--- a/src/testing/Python.Test.csproj
+++ b/src/testing/Python.Test.csproj
@@ -1,6 +1,6 @@
- net6.0
+ net9.0
true
true
..\pythonnet.snk