Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
5d6e5d5
use reference types instead of IntPtr where possible in runtime.cs
lostmsu Oct 17, 2021
2d33902
switched converter.cs to the new style references
lostmsu Oct 17, 2021
f8b761a
switched most of classbase.cs to the new style references (except cro…
lostmsu Oct 17, 2021
09d8e41
switched pyobject.cs to the new style references
lostmsu Oct 17, 2021
1b58cf4
mostly switched moduleobject.cs to the new style references
lostmsu Oct 17, 2021
c05c6ec
switched methodbinder.cs to the new style references
lostmsu Oct 17, 2021
d626f7e
partially switched classderived.cs to the new reference style
lostmsu Oct 17, 2021
ff60ec4
switched arrayobject.cs to the new style references
lostmsu Oct 17, 2021
0010fa0
switched delegatemanager.cs to the new style references
lostmsu Oct 17, 2021
178a359
partially switched metatype.cs to the new style references
lostmsu Oct 18, 2021
9764b25
switched typemanager.cs to the new style references
lostmsu Oct 18, 2021
11edcc3
switched pytype.cs to the new style references
lostmsu Oct 18, 2021
2e71874
mass enable nullable types
lostmsu Oct 18, 2021
3076040
fixed nullablity in arrayobject.cs
lostmsu Oct 18, 2021
56f3bd5
fixed nullability in assemblymanager.cs
lostmsu Oct 18, 2021
58cb0e6
switched classmanager.cs to the new style references
lostmsu Oct 18, 2021
2095b46
switched classobject.cs to the new style references
lostmsu Oct 18, 2021
f6b84da
partially switched managedtype.cs to the new style references
lostmsu Oct 18, 2021
ee65632
partially switched classmanager.cs to the new style references
lostmsu Oct 18, 2021
5266dc4
PyIdentifier public members to return borrowed references
lostmsu Oct 6, 2021
0bc3670
added nullability annotations to methodbinder.cs
lostmsu Oct 18, 2021
de9a8cb
switched methodbinding.cs and methodobject.cs to the new style refere…
lostmsu Oct 18, 2021
9195c30
switched overload.cs to the new style references
lostmsu Oct 18, 2021
590de7a
switched propertyobject.cs to the new style references
lostmsu Oct 18, 2021
7fa537a
switched delegateobject.cs to the new style references
lostmsu Oct 18, 2021
49124fc
switched module.cs to the new style references
lostmsu Oct 18, 2021
9db9b0b
nullability annotations for PyObject
lostmsu Oct 18, 2021
00fd17a
switched modulefunctionobject.cs to the new style references
lostmsu Oct 18, 2021
5798b41
minor refactorings
lostmsu Oct 18, 2021
ebdf7c5
partially switched moduleobject.cs and importhook.cs to the new style…
lostmsu Oct 18, 2021
5ad09e4
switched exceptions.cs to the new style references
lostmsu Oct 18, 2021
d1abd9a
switched interfaceobject.cs to the new style references
lostmsu Oct 18, 2021
43a862a
switched pythonexception.cs to the new style references
lostmsu Oct 18, 2021
1d80162
switched pytuple.cs to the new style references
lostmsu Oct 18, 2021
0241b38
switched eventobject.cs and eventbiding.cs to the new style references
lostmsu Oct 18, 2021
2ac952a
switched all PyObject derived classes to the new style references
lostmsu Oct 18, 2021
7adf98a
implemented non-confusing PyModule_AddObject
lostmsu Oct 18, 2021
2dd3f8f
switched pythonengine.cs to the new style references
lostmsu Oct 18, 2021
3b79019
switched fieldobject.cs and constructorbinding.cs to the new style re…
lostmsu Oct 18, 2021
9b990c1
switched finalizer.cs to the new style references
lostmsu Oct 19, 2021
027e529
switched debughelper.cs to the new style references
lostmsu Oct 19, 2021
4793818
switched converter extensions and sample codecs to the new style refe…
lostmsu Oct 19, 2021
0d60500
switched collection wrappers (from sample codec) to the new style ref…
lostmsu Oct 19, 2021
cf606a2
switched iterator.cs and indexer.cs to the new style references
lostmsu Oct 19, 2021
bb84c48
getting rid of a few minor warnings and compile errors
lostmsu Oct 19, 2021
e295679
switched to new references in some tests
lostmsu Oct 19, 2021
7a9e411
switched state serialization to new reference types (untested)
lostmsu Oct 19, 2021
9a9ed3b
minor error fixes
lostmsu Oct 19, 2021
581f695
assume remaning manual refcounting is not needed, because we use smar…
lostmsu Oct 19, 2021
07f1657
fixed new reference uses, that are not allowed in C#
lostmsu Oct 19, 2021
7deebd4
renamed parameter in tp_dealloc functions for clarity
lostmsu Oct 19, 2021
8619e77
allowed untested calls to PyObject_GC_Del and XDecref (3 in total)
lostmsu Oct 19, 2021
672aef6
fixed compile errors in TypeMethod (untested)
lostmsu Oct 19, 2021
c4909d4
workaround for analyzer not permitting copying a reference as the las…
lostmsu Oct 19, 2021
6fa2004
switched tests to match the new reference changes
lostmsu Oct 19, 2021
14949fb
fixed thunk loading for slots, that use new reference types
lostmsu Oct 19, 2021
0728e21
fixed PyObject_DelAttr load from DLL failing
lostmsu Oct 19, 2021
fe4c481
fixed uses of Marshal.Read/Marshal.Write overloads with first argumen…
lostmsu Oct 19, 2021
4346d41
fixed OnSerialized and OnDeserialized in PyObject not being typed cor…
lostmsu Oct 19, 2021
62e193a
fixed bad equality comparisons
lostmsu Oct 20, 2021
2fa8b9c
improved reliability of Clean and Dealloc implementations
lostmsu Oct 20, 2021
d6607b0
bad if condition
lostmsu Oct 20, 2021
6335d97
improved GetThunk reliability
lostmsu Oct 20, 2021
d649d6c
fixed circular dependency in Runtime PyMembers and InternString initi…
lostmsu Oct 20, 2021
d1bc193
tiny refactor
lostmsu Oct 20, 2021
32c4bb6
switched generictype.cs to the new style references
lostmsu Oct 20, 2021
a1427ac
increfs in OnSave are no longer necessary with the new references
lostmsu Oct 20, 2021
cd97a46
fixed MethodBinding failing for reference types
lostmsu Oct 20, 2021
05ecbcf
nullability annotation fix in MaybeMethodBase
lostmsu Oct 20, 2021
a3591b6
minor improvements
lostmsu Oct 20, 2021
7ed0c7a
WIP
lostmsu Oct 24, 2021
d6a853f
avoid generating and handling useless SerializationException when May…
lostmsu Oct 28, 2021
b0c25c1
finalizer does not attempt to finalize objects when runtime is shut down
lostmsu Oct 28, 2021
5ca474a
PyType Dict and MRO properties to assist debugging
lostmsu Oct 28, 2021
48078b3
WIP 2
lostmsu Oct 28, 2021
a624dd8
fixed PyObject disposal crashing when runtime is still finalizing
lostmsu Oct 29, 2021
e7ab071
arrays: use 64 bit indexing, and avoid first chance .NET exceptions o…
lostmsu Oct 29, 2021
cbe1dd2
refactored conditional ClassBase slot initialization
lostmsu Oct 29, 2021
d5f1c48
removed DisposePythonWrappersForClrTypes
lostmsu Oct 29, 2021
74d87c5
simplified outdated condition in ClassBase.tp_clear
lostmsu Oct 29, 2021
82d6c33
sprinkled a few DebuggerHidden to make debugging easier
lostmsu Oct 29, 2021
eeebcd7
fixed derived classes not inheriting slots correctly
lostmsu Oct 29, 2021
8ee8d3d
remove unused TypeManager._slotImpls
lostmsu Oct 29, 2021
1a4ada7
fixed TestRuntime not building in Release mode
lostmsu Oct 30, 2021
a610aa3
can't really clear managed references to Python objects from ManagedT…
lostmsu Oct 30, 2021
03f32cb
PythonException is serializable
lostmsu Oct 30, 2021
b1c9f5b
EventObject no longer used for static events. EventBinding is constru…
lostmsu Oct 30, 2021
cb4bb9a
use a special class to stub .NET types that no longer exist after a d…
lostmsu Nov 2, 2021
652f946
make EventHandlerCollection serializable
lostmsu Nov 2, 2021
84db670
fixed MaybeMemberInfo always failing for properties
lostmsu Nov 2, 2021
56fafe3
fixed construct_removed_class domain reload test case
lostmsu Nov 2, 2021
d33dcdd
domain reload test runner can run test by index
lostmsu Nov 2, 2021
b737e10
minor docs change
lostmsu Nov 2, 2021
d3e4fba
assert check in GetUnmanagedBaseType for null base
lostmsu Nov 2, 2021
e003e12
PythonEngine .Exec and .Eval no longer work with raw pointers
lostmsu Nov 9, 2021
d0a6f44
a few annotation to ease debugging
lostmsu Nov 9, 2021
e31f7ba
ensure Python types continue to exist when registered decoders for th…
lostmsu Nov 9, 2021
48c0dfc
GC-related WIP
lostmsu Nov 9, 2021
44d65d9
merge latest master
lostmsu Nov 23, 2021
cb58147
merge latest changes from upstream
lostmsu Nov 23, 2021
2fdbf0e
added TraceAlloc solution configuration
lostmsu Nov 24, 2021
a8ef06c
fixed sending PyObject across domain boundary
lostmsu Nov 24, 2021
7167229
fixed accidental premature disposal of Runtime.PyNone
lostmsu Nov 24, 2021
ab11fa2
made freeing GCHandles more robust
lostmsu Nov 24, 2021
7a4daeb
removed bad assert in generated constructor for derived classes
lostmsu Nov 24, 2021
e422367
fixed __pyobj__ access
lostmsu Nov 24, 2021
a74ea86
minor
lostmsu Nov 24, 2021
0325a8c
fixed Python derived types trying to double-free GCHandle when collec…
lostmsu Nov 24, 2021
85fab3b
reinstate collection assert on shutdown from Python
lostmsu Nov 24, 2021
932fce2
fixed crash when Python derived class instances survive past early sh…
lostmsu Nov 24, 2021
c2e207a
delay nulling GC handles of reflected instances until the last moment…
lostmsu Nov 24, 2021
c8f0f09
fixed assert in XDecref in case _Py_IsFinalizing is not present
lostmsu Nov 24, 2021
e269cf0
when initialized from Python, reset slots implemented in CLR: CLR mig…
lostmsu Nov 25, 2021
d7d5cb7
fixed minor warnings
lostmsu Nov 25, 2021
d6edace
fixed line endings in intern_.cs
lostmsu Nov 25, 2021
a86994f
use NonCopyableAnalyzer 0.7.0-m05
lostmsu Nov 25, 2021
2e040ea
Merge pull request #2 from losttech/ManagedType-DontKeepBorrowedRefs
lostmsu Dec 9, 2021
b614dba
merge latest master
lostmsu Dec 9, 2021
f09a48b
fixed MacOS bad assembly test by using PythonDLL (which is never a .N…
lostmsu Dec 9, 2021
3794fea
Merge branch 'master' into precise-API-references
lostmsu Dec 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
switched tests to match the new reference changes
  • Loading branch information
lostmsu committed Oct 19, 2021
commit 6fa2004137d3d81a105a1adde78f4a08922b1893
4 changes: 2 additions & 2 deletions src/embed_tests/CodecGroups.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public void Encodes()
};

var uri = group.TryEncode(new Uri("data:"));
var clrObject = (CLRObject)ManagedType.GetManagedObject(uri.Handle);
var clrObject = (CLRObject)ManagedType.GetManagedObject(uri);
Assert.AreSame(encoder1, clrObject.inst);
Assert.AreNotSame(encoder2, clrObject.inst);

var tuple = group.TryEncode(Tuple.Create(1));
clrObject = (CLRObject)ManagedType.GetManagedObject(tuple.Handle);
clrObject = (CLRObject)ManagedType.GetManagedObject(tuple);
Assert.AreSame(encoder0, clrObject.inst);
}

Expand Down
2 changes: 1 addition & 1 deletion src/embed_tests/Inheritance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public int XProp
{
return scope.Eval<int>($"super(this.__class__, this).{nameof(XProp)}");
}
catch (PythonException ex) when (ex.Type.Handle == Exceptions.AttributeError)
catch (PythonException ex) when (PythonReferenceComparer.Instance.Equals(ex.Type, Exceptions.AttributeError))
{
if (this.extras.TryGetValue(nameof(this.XProp), out object value))
return (int)value;
Expand Down
12 changes: 3 additions & 9 deletions src/embed_tests/References.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,9 @@ public void MoveToPyObject_SetsNull()
public void CanBorrowFromNewReference()
{
var dict = new PyDict();
NewReference reference = Runtime.PyDict_Items(dict.Reference);
try
{
PythonException.ThrowIfIsNotZero(Runtime.PyList_Reverse(reference));
}
finally
{
reference.Dispose();
}
using NewReference reference = Runtime.PyDict_Items(dict.Reference);
BorrowedReference borrowed = reference.BorrowOrThrow();
PythonException.ThrowIfIsNotZero(Runtime.PyList_Reverse(borrowed));
}
}
}
8 changes: 4 additions & 4 deletions src/embed_tests/TestCustomMarshal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public static void GetManagedStringTwice()
{
const string expected = "FooBar";

IntPtr op = Runtime.Runtime.PyString_FromString(expected);
string s1 = Runtime.Runtime.GetManagedString(op);
string s2 = Runtime.Runtime.GetManagedString(op);
using var op = Runtime.Runtime.PyString_FromString(expected);
string s1 = Runtime.Runtime.GetManagedString(op.BorrowOrThrow());
string s2 = Runtime.Runtime.GetManagedString(op.Borrow());

Assert.AreEqual(1, Runtime.Runtime.Refcount(op));
Assert.AreEqual(1, Runtime.Runtime.Refcount(op.Borrow()));
Assert.AreEqual(expected, s1);
Assert.AreEqual(expected, s2);
}
Expand Down
10 changes: 5 additions & 5 deletions src/embed_tests/TestDomainReload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ from Python.EmbeddingTest.Domain import MyClass
{
Debug.Assert(obj.AsManagedObject(type).GetType() == type);
// We only needs its Python handle
PyRuntime.XIncref(obj.Handle);
PyRuntime.XIncref(obj);
return obj.Handle;
}
}
Expand All @@ -127,16 +127,16 @@ public override ValueType Execute(ValueType arg)
{
// handle refering a clr object created in previous domain,
// it should had been deserialized and became callable agian.
IntPtr handle = (IntPtr)arg;
using var handle = NewReference.DangerousFromPointer((IntPtr)arg);
try
{
using (Py.GIL())
{
IntPtr tp = Runtime.Runtime.PyObject_TYPE(handle);
IntPtr tp_clear = Marshal.ReadIntPtr(tp, TypeOffset.tp_clear);
BorrowedReference tp = Runtime.Runtime.PyObject_TYPE(handle.Borrow());
IntPtr tp_clear = Util.ReadIntPtr(tp, TypeOffset.tp_clear);
Assert.That(tp_clear, Is.Not.Null);

using (PyObject obj = new PyObject(handle))
using (PyObject obj = new PyObject(handle.Steal()))
{
obj.InvokeMethod("Method");
obj.InvokeMethod("StaticMethod");
Expand Down
2 changes: 1 addition & 1 deletion src/embed_tests/TestFinalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public void ValidateRefCount()
Assert.AreEqual(ptr, e.Handle);
Assert.AreEqual(2, e.ImpactedObjects.Count);
// Fix for this test, don't do this on general environment
Runtime.Runtime.XIncref(e.Handle);
Runtime.Runtime.XIncref(e.Reference);
return false;
};
Finalizer.Instance.IncorrectRefCntResolver += handler;
Expand Down
1 change: 0 additions & 1 deletion src/embed_tests/TestPyInt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public void TestCtorSByte()
public void TestCtorPyObject()
{
var i = new PyInt(5);
Runtime.Runtime.XIncref(i.Handle);
var a = new PyInt(i);
Assert.AreEqual(5, a.ToInt32());
}
Expand Down
4 changes: 2 additions & 2 deletions src/embed_tests/TestPyObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void GetAttrDefault_IgnoresAttributeErrorOnly()

public class PyObjectTestMethods
{
public string RaisesAttributeError => throw new PythonException(new PyType(new BorrowedReference(Exceptions.AttributeError)), value: null, traceback: null);
public string RaisesTypeError => throw new PythonException(new PyType(new BorrowedReference(Exceptions.TypeError)), value: null, traceback: null);
public string RaisesAttributeError => throw new PythonException(new PyType(Exceptions.AttributeError), value: null, traceback: null);
public string RaisesTypeError => throw new PythonException(new PyType(Exceptions.TypeError), value: null, traceback: null);
}
}
55 changes: 28 additions & 27 deletions src/embed_tests/TestRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,31 @@ public static void Py_IsInitializedValue()
public static void RefCountTest()
{
Runtime.Runtime.Py_Initialize();
IntPtr op = Runtime.Runtime.PyString_FromString("FooBar");
using var op = Runtime.Runtime.PyString_FromString("FooBar");

// New object RefCount should be one
Assert.AreEqual(1, Runtime.Runtime.Refcount(op));
Assert.AreEqual(1, Runtime.Runtime.Refcount(op.BorrowOrThrow()));

// Checking refcount didn't change refcount
Assert.AreEqual(1, Runtime.Runtime.Refcount(op));
Assert.AreEqual(1, Runtime.Runtime.Refcount(op.Borrow()));

// New reference doesn't increase refcount
IntPtr p = op;
// Borrowing a reference doesn't increase refcount
BorrowedReference p = op.Borrow();
Assert.AreEqual(1, Runtime.Runtime.Refcount(p));

// Py_IncRef/Py_DecRef increase and decrease RefCount
Runtime.Runtime.Py_IncRef(op);
Assert.AreEqual(2, Runtime.Runtime.Refcount(op));
Runtime.Runtime.Py_DecRef(op);
Assert.AreEqual(1, Runtime.Runtime.Refcount(op));
Runtime.Runtime.Py_IncRef(op.Borrow());
Assert.AreEqual(2, Runtime.Runtime.Refcount(p));
Runtime.Runtime.Py_DecRef(StolenReference.DangerousFromPointer(op.DangerousGetAddress()));
Assert.AreEqual(1, Runtime.Runtime.Refcount(p));

// XIncref/XDecref increase and decrease RefCount
Runtime.Runtime.XIncref(op);
Assert.AreEqual(2, Runtime.Runtime.Refcount(op));
Runtime.Runtime.XDecref(op);
Assert.AreEqual(1, Runtime.Runtime.Refcount(op));
Runtime.Runtime.XIncref(p);
Assert.AreEqual(2, Runtime.Runtime.Refcount(p));
Runtime.Runtime.XDecref(p);
Assert.AreEqual(1, Runtime.Runtime.Refcount(p));

op.Dispose();

Runtime.Runtime.Py_Finalize();
}
Expand All @@ -71,22 +73,23 @@ public static void PyCheck_Iter_PyObject_IsIterable_Test()
Runtime.Native.ABI.Initialize(Runtime.Runtime.PyVersion);

// Tests that a python list is an iterable, but not an iterator
using (var pyList = NewReference.DangerousFromPointer(Runtime.Runtime.PyList_New(0)))
using (var pyListNew = Runtime.Runtime.PyList_New(0))
{
BorrowedReference pyList = pyListNew.BorrowOrThrow();
Assert.IsFalse(Runtime.Runtime.PyIter_Check(pyList));
Assert.IsTrue(Runtime.Runtime.PyObject_IsIterable(pyList));

// Tests that a python list iterator is both an iterable and an iterator
using var pyListIter = Runtime.Runtime.PyObject_GetIter(pyList);
Assert.IsTrue(Runtime.Runtime.PyObject_IsIterable(pyListIter));
Assert.IsTrue(Runtime.Runtime.PyIter_Check(pyListIter));
Assert.IsTrue(Runtime.Runtime.PyObject_IsIterable(pyListIter.BorrowOrThrow()));
Assert.IsTrue(Runtime.Runtime.PyIter_Check(pyListIter.Borrow()));
}

// Tests that a python float is neither an iterable nor an iterator
using (var pyFloat = NewReference.DangerousFromPointer(Runtime.Runtime.PyFloat_FromDouble(2.73)))
using (var pyFloat = Runtime.Runtime.PyFloat_FromDouble(2.73))
{
Assert.IsFalse(Runtime.Runtime.PyObject_IsIterable(pyFloat));
Assert.IsFalse(Runtime.Runtime.PyIter_Check(pyFloat));
Assert.IsFalse(Runtime.Runtime.PyObject_IsIterable(pyFloat.BorrowOrThrow()));
Assert.IsFalse(Runtime.Runtime.PyIter_Check(pyFloat.Borrow()));
}

Runtime.Runtime.Py_Finalize();
Expand All @@ -104,19 +107,17 @@ public static void PyCheck_Iter_PyObject_IsIterable_ThreadingLock_Test()
// Create an instance of threading.Lock, which is one of the very few types that does not have the
// TypeFlags.HaveIter set in Python 2. This tests a different code path in PyObject_IsIterable and PyIter_Check.
using var threading = Runtime.Runtime.PyImport_ImportModule("threading");
Exceptions.ErrorCheck(threading);
var threadingDict = Runtime.Runtime.PyModule_GetDict(threading);
BorrowedReference threadingDict = Runtime.Runtime.PyModule_GetDict(threading.BorrowOrThrow());
Exceptions.ErrorCheck(threadingDict);
var lockType = Runtime.Runtime.PyDict_GetItemString(threadingDict, "Lock");
BorrowedReference lockType = Runtime.Runtime.PyDict_GetItemString(threadingDict, "Lock");
if (lockType.IsNull)
throw PythonException.ThrowLastAsClrException();

using var args = NewReference.DangerousFromPointer(Runtime.Runtime.PyTuple_New(0));
using var lockInstance = Runtime.Runtime.PyObject_CallObject(lockType, args);
Exceptions.ErrorCheck(lockInstance);
using var args = Runtime.Runtime.PyTuple_New(0);
using var lockInstance = Runtime.Runtime.PyObject_CallObject(lockType, args.Borrow());

Assert.IsFalse(Runtime.Runtime.PyObject_IsIterable(lockInstance));
Assert.IsFalse(Runtime.Runtime.PyIter_Check(lockInstance));
Assert.IsFalse(Runtime.Runtime.PyObject_IsIterable(lockInstance.BorrowOrThrow()));
Assert.IsFalse(Runtime.Runtime.PyIter_Check(lockInstance.Borrow()));
}
finally
{
Expand Down
4 changes: 3 additions & 1 deletion src/runtime/exceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,14 @@ internal static void SetArgsAndCause(BorrowedReference ob, Exception e)
/// Shortcut for (pointer == NULL) -&gt; throw PythonException
/// </summary>
/// <param name="pointer">Pointer to a Python object</param>
internal static void ErrorCheck(BorrowedReference pointer)
internal static BorrowedReference ErrorCheck(BorrowedReference pointer)
{
if (pointer.IsNull)
{
throw PythonException.ThrowLastAsClrException();
}

return pointer;
}

internal static void ErrorCheck(IntPtr pointer) => ErrorCheck(new BorrowedReference(pointer));
Expand Down
1 change: 1 addition & 0 deletions src/runtime/finalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public IncorrectFinalizeArgs(IntPtr handle, IReadOnlyCollection<IntPtr> imacted)
ImpactedObjects = imacted;
}
public IntPtr Handle { get; }
public BorrowedReference Reference => new(Handle);
public IReadOnlyCollection<IntPtr> ImpactedObjects { get; }
}

Expand Down
19 changes: 1 addition & 18 deletions src/runtime/pythonexception.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,24 +424,7 @@ internal static void ThrowIfIsNull(in NewReference ob)
}
}
internal static BorrowedReference ThrowIfIsNull(BorrowedReference ob)
{
if (ob == null)
{
throw ThrowLastAsClrException();
}

return ob;
}

internal static IntPtr ThrowIfIsNull(IntPtr ob)
{
if (ob == IntPtr.Zero)
{
throw ThrowLastAsClrException();
}

return ob;
}
=> Exceptions.ErrorCheck(ob);

internal static void ThrowIfIsNotZero(int value)
{
Expand Down