Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Changes from all commits
Commits
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
25 changes: 6 additions & 19 deletions 25 src/runtime/runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,6 @@ private static void NullGCHandles(IEnumerable<IntPtr> objects)
internal static PyType PyNoneType;
internal static BorrowedReference PyTypeType => new(Delegates.PyType_Type);

internal static int* Py_NoSiteFlag;

internal static PyObject PyBytesType;
internal static NativeFunc* _PyObject_NextNotImplemented;

Expand Down Expand Up @@ -1881,24 +1879,11 @@ internal static IntPtr PyCapsule_GetPointer(BorrowedReference capsule, IntPtr na

internal static void SetNoSiteFlag()
{
var loader = LibraryLoader.Instance;
IntPtr dllLocal = IntPtr.Zero;
if (_PythonDll != "__Internal")
{
dllLocal = loader.Load(_PythonDll);
}
try
{
Py_NoSiteFlag = (int*)loader.GetFunction(dllLocal, "Py_NoSiteFlag");
*Py_NoSiteFlag = 1;
}
finally
TryUsingDll(() =>
{
if (dllLocal != IntPtr.Zero)
{
loader.Free(dllLocal);
}
}
*Delegates.Py_NoSiteFlag = 1;
return *Delegates.Py_NoSiteFlag;
});
}

internal static class Delegates
Expand Down Expand Up @@ -2170,6 +2155,7 @@ static Delegates()
catch (MissingMethodException) { }

PyType_Type = GetFunctionByName(nameof(PyType_Type), GetUnmanagedDll(_PythonDll));
Py_NoSiteFlag = (int*)GetFunctionByName(nameof(Py_NoSiteFlag), GetUnmanagedDll(_PythonDll));
}

static global::System.IntPtr GetUnmanagedDll(string? libraryName)
Expand Down Expand Up @@ -2426,6 +2412,7 @@ static Delegates()
internal static delegate* unmanaged[Cdecl]<BorrowedReference, void> _Py_NewReference { get; }
internal static delegate* unmanaged[Cdecl]<int> _Py_IsFinalizing { get; }
internal static IntPtr PyType_Type { get; }
internal static int* Py_NoSiteFlag { get; }
}
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.