Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 039b3ca

Browse files
committed
a few extra assertions
1 parent 38b3f01 commit 039b3ca

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/runtime/clrobject.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics;
23
using System.Runtime.InteropServices;
34

45
namespace Python.Runtime
@@ -85,6 +86,7 @@ internal static CLRObject Restore(object ob, IntPtr pyHandle, InterDomainContext
8586
pyHandle = pyHandle,
8687
tpHandle = Runtime.PyObject_TYPE(pyHandle)
8788
};
89+
Debug.Assert(co.tpHandle != IntPtr.Zero);
8890
co.Load(context);
8991
return co;
9092
}

src/runtime/native/TypeOffset.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ internal static void Use(ITypeOffsets offsets)
8585
internal static Dictionary<string, int> GetOffsets()
8686
{
8787
var properties = typeof(TypeOffset).GetProperties(FieldFlags);
88-
return properties.ToDictionary(
89-
keySelector: p => p.Name,
90-
elementSelector: p => (int)p.GetValue(obj: null, index: null));
88+
var result = properties.ToDictionary(
89+
keySelector: p => p.Name,
90+
elementSelector: p => (int)p.GetValue(obj: null, index: null));
91+
Debug.Assert(result.Values.Any(v => v != 0));
92+
return result;
9193
}
9294

9395
internal static int GetOffsetUncached(string name)

0 commit comments

Comments
 (0)