◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].

### Added

### Changed
- Drop support for Python 2, 3.4, and 3.5
- `clr.AddReference` may now throw errors besides `FileNotFoundException`, that provide more
Expand Down
5 changes: 5 additions & 0 deletions src/runtime/BorrowedReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,10 @@ public BorrowedReference(IntPtr pointer)
{
this.pointer = pointer;
}
}
}
8 changes: 8 additions & 0 deletions src/runtime/NewReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ public PyObject MoveToPyObject()
return result;
}

/// <summary>
/// Removes this reference to a Python object, and sets it to <c>null</c>.
/// </summary>
Expand Down
6 changes: 5 additions & 1 deletion src/runtime/clrobject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ static CLRObject GetInstance(object ob)
return GetInstance(ob, cc.tpHandle);
}


internal static IntPtr GetInstHandle(object ob, IntPtr pyType)
{
CLRObject co = GetInstance(ob, pyType);
2 changes: 2 additions & 0 deletions src/runtime/managedtype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ internal void FreeGCHandle()
}
}

/// <summary>
/// Given a Python object, return the associated managed object or null.
/// </summary>
Expand Down
16 changes: 15 additions & 1 deletion src/runtime/runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,8 @@ internal static unsafe IntPtr PyObject_TYPE(IntPtr op)
? new IntPtr((void*)(*((uint*)p + n)))
: new IntPtr((void*)(*((ulong*)p + n)));
}

/// <summary>
/// Managed version of the standard Python C API PyObject_Type call.
Expand Down Expand Up @@ -1202,6 +1204,8 @@ internal static long PyObject_Size(IntPtr pointer)
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern bool PyNumber_Check(IntPtr ob);

internal static bool PyInt_Check(IntPtr ob)
{
return PyObject_TypeCheck(ob, PyIntType);
Expand Down Expand Up @@ -1291,6 +1295,8 @@ internal static object PyLong_AsUnsignedLong(IntPtr value)
return PyLong_AsUnsignedLong64(value);
}

[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern long PyLong_AsLongLong(IntPtr value);

Expand Down Expand Up @@ -1829,11 +1835,15 @@ internal static IntPtr PyTuple_New(long size)
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr PyTuple_New(IntPtr size);

internal static IntPtr PyTuple_GetItem(IntPtr pointer, long index)
{
return PyTuple_GetItem(pointer, new IntPtr(index));
}

[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr PyTuple_GetItem(IntPtr pointer, IntPtr index);

Expand Down Expand Up @@ -1950,10 +1960,14 @@ internal static bool PyType_Check(IntPtr ob)

[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern bool PyType_IsSubtype(IntPtr t1, IntPtr t2);

internal static bool PyObject_TypeCheck(IntPtr ob, IntPtr tp)
{
IntPtr t = PyObject_TYPE(ob);
return (t == tp) || PyType_IsSubtype(t, tp);
}

Expand Down
14 changes: 14 additions & 0 deletions src/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,20 @@ def test_boxed_value_type_mutation_result():
assert items[i].X == i + 1
assert items[i].Y == i + 1


def test_special_array_creation():
"""Test using the Array[<type>] syntax for creating arrays."""
Expand Down
Toggle all file notes Toggle all file annotations