Skip to content

Commit 0456436

Browse files
Fix compiler warnings
1 parent d72be7f commit 0456436

File tree

7 files changed

+16
-26
lines changed

7 files changed

+16
-26
lines changed

Directory.Build.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<AssemblyCopyright>Copyright (c) 2006-2021 The Contributors of the Python.NET Project</AssemblyCopyright>
55
<AssemblyCompany>pythonnet</AssemblyCompany>
66
<AssemblyProduct>Python.NET</AssemblyProduct>
7-
<LangVersion>10.0</LangVersion>
87
<IsPackable>false</IsPackable>
98
</PropertyGroup>
109
</Project>

src/embed_tests/StateSerialization/MethodSerialization.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.IO;
1+
/*using System.IO;
22
using System.Reflection;
33
44
using NUnit.Framework;
@@ -44,3 +44,4 @@ public class MethodTestHost
4444
public MethodTestHost(int _) { }
4545
public void Generic<T>(T item, T[] array, ref T @ref) { }
4646
}
47+
*/

src/runtime/MethodBinder.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,6 @@ internal Binding Bind(BorrowedReference inst, BorrowedReference args, BorrowedRe
793793

794794
static BorrowedReference HandleParamsArray(BorrowedReference args, int arrayStart, int pyArgCount, out NewReference tempObject)
795795
{
796-
BorrowedReference op;
797796
tempObject = default;
798797
// for a params method, we may have a sequence or single/multiple items
799798
// 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
806805
if (!Runtime.PyString_Check(item) && (Runtime.PySequence_Check(item) || (ManagedType.GetManagedObject(item) as CLRObject)?.inst is IEnumerable))
807806
{
808807
// it's a sequence (and not a string), so we use it as the op
809-
op = item;
808+
return item;
810809
}
811810
else
812811
{
813812
tempObject = Runtime.PyTuple_GetSlice(args, arrayStart, pyArgCount);
814-
op = tempObject.Borrow();
813+
return tempObject.Borrow();
815814
}
816815
}
817816
else
818817
{
819818
tempObject = Runtime.PyTuple_GetSlice(args, arrayStart, pyArgCount);
820-
op = tempObject.Borrow();
819+
return tempObject.Borrow();
821820
}
822-
return op;
823821
}
824822

825823
/// <summary>

src/runtime/Native/NewReference.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ref struct NewReference
1515

1616
/// <summary>Creates a <see cref="NewReference"/> pointing to the same object</summary>
1717
[DebuggerHidden]
18-
public NewReference(BorrowedReference reference, bool canBeNull = false)
18+
public NewReference(scoped BorrowedReference reference, bool canBeNull = false)
1919
{
2020
var address = canBeNull
2121
? reference.DangerousGetAddressOrNull()
@@ -157,15 +157,15 @@ public static bool IsNull(this in NewReference reference)
157157

158158
[Pure]
159159
[DebuggerHidden]
160-
public static BorrowedReference BorrowNullable(this in NewReference reference)
160+
public static BorrowedReference BorrowNullable(this scoped in NewReference reference)
161161
=> new(NewReference.DangerousGetAddressOrNull(reference));
162162
[Pure]
163163
[DebuggerHidden]
164-
public static BorrowedReference Borrow(this in NewReference reference)
164+
public static BorrowedReference Borrow(this scoped in NewReference reference)
165165
=> reference.IsNull() ? throw new NullReferenceException() : reference.BorrowNullable();
166166
[Pure]
167167
[DebuggerHidden]
168-
public static BorrowedReference BorrowOrThrow(this in NewReference reference)
168+
public static BorrowedReference BorrowOrThrow(this scoped in NewReference reference)
169169
=> reference.IsNull() ? throw PythonException.ThrowLastAsClrException() : reference.BorrowNullable();
170170
}
171171
}

src/runtime/Native/StolenReference.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static StolenReference Take(ref IntPtr ptr)
2828
}
2929
[MethodImpl(MethodImplOptions.AggressiveInlining)]
3030
[DebuggerHidden]
31-
public static StolenReference TakeNullable(ref IntPtr ptr)
31+
public static StolenReference TakeNullable(scoped ref IntPtr ptr)
3232
{
3333
var stolenAddr = ptr;
3434
ptr = IntPtr.Zero;

src/runtime/Runtime.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,8 @@ internal static void Initialize(bool initSigs = false)
157157
// Initialize modules that depend on the runtime class.
158158
AssemblyManager.Initialize();
159159
OperatorMethod.Initialize();
160-
if (RuntimeData.HasStashData())
161-
{
162-
RuntimeData.RestoreRuntimeData();
163-
}
164-
else
165-
{
166-
PyCLRMetaType = MetaType.Initialize();
167-
ImportHook.Initialize();
168-
}
160+
PyCLRMetaType = MetaType.Initialize();
161+
ImportHook.Initialize();
169162
Exceptions.Initialize();
170163

171164
// Need to add the runtime directory to sys.path so that we
@@ -269,8 +262,6 @@ internal static void Shutdown()
269262
{
270263
// avoid saving dead objects
271264
TryCollectingGarbage(runs: 3);
272-
273-
RuntimeData.Stash();
274265
}
275266

276267
AssemblyManager.Shutdown();
@@ -832,7 +823,7 @@ public static int Py_Main(int argc, string[] argv)
832823

833824
internal static IntPtr Py_GetBuildInfo() => Delegates.Py_GetBuildInfo();
834825

835-
const PyCompilerFlags Utf8String = PyCompilerFlags.IGNORE_COOKIE | PyCompilerFlags.SOURCE_IS_UTF8;
826+
private static readonly PyCompilerFlags Utf8String = PyCompilerFlags.IGNORE_COOKIE | PyCompilerFlags.SOURCE_IS_UTF8;
836827

837828
internal static int PyRun_SimpleString(string code)
838829
{
@@ -1715,7 +1706,7 @@ internal static bool PyType_IsSameAsOrSubtype(BorrowedReference type, BorrowedRe
17151706
internal static NewReference PyType_GenericAlloc(BorrowedReference type, nint n) => Delegates.PyType_GenericAlloc(type, n);
17161707

17171708
internal static IntPtr PyType_GetSlot(BorrowedReference type, TypeSlotID slot) => Delegates.PyType_GetSlot(type, slot);
1718-
internal static NewReference PyType_FromSpecWithBases(in NativeTypeSpec spec, BorrowedReference bases) => Delegates.PyType_FromSpecWithBases(in spec, bases);
1709+
internal static NewReference PyType_FromSpecWithBases(scoped in NativeTypeSpec spec, BorrowedReference bases) => Delegates.PyType_FromSpecWithBases(in spec, bases);
17191710

17201711
/// <summary>
17211712
/// 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.

src/runtime/StateSerialization/RuntimeData.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
/*using System;
22
using System.Collections;
33
using System.Collections.Generic;
44
using System.Collections.ObjectModel;
@@ -210,3 +210,4 @@ internal static IFormatter CreateFormatter()
210210
}
211211
}
212212
}
213+
*/

0 commit comments

Comments
 (0)