| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fabb22c commit 7e5cc29
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -495,8 +495,6 @@ private static void NullGCHandles(IEnumerable<IntPtr> objects) | |||
| 495 | 495 | internal static PyType PyNoneType; | |
| 496 | 496 | internal static BorrowedReference PyTypeType => new(Delegates.PyType_Type); | |
| 497 | 497 | ||
| 498 | - internal static int* Py_NoSiteFlag; | ||
| 499 | - | ||
| 500 | 498 | internal static PyObject PyBytesType; | |
| 501 | 499 | internal static NativeFunc* _PyObject_NextNotImplemented; | |
| 502 | 500 | ||
@@ -1881,24 +1879,11 @@ internal static IntPtr PyCapsule_GetPointer(BorrowedReference capsule, IntPtr na | |||
| 1881 | 1879 | ||
| 1882 | 1880 | internal static void SetNoSiteFlag() | |
| 1883 | 1881 | { | |
| 1884 | - var loader = LibraryLoader.Instance; | ||
| 1885 | - IntPtr dllLocal = IntPtr.Zero; | ||
| 1886 | - if (_PythonDll != "__Internal") | ||
| 1887 | - { | ||
| 1888 | - dllLocal = loader.Load(_PythonDll); | ||
| 1889 | - } | ||
| 1890 | - try | ||
| 1891 | - { | ||
| 1892 | - Py_NoSiteFlag = (int*)loader.GetFunction(dllLocal, "Py_NoSiteFlag"); | ||
| 1893 | - *Py_NoSiteFlag = 1; | ||
| 1894 | - } | ||
| 1895 | - finally | ||
| 1882 | + TryUsingDll(() => | ||
| 1896 | 1883 | { | |
| 1897 | - if (dllLocal != IntPtr.Zero) | ||
| 1898 | - { | ||
| 1899 | - loader.Free(dllLocal); | ||
| 1900 | - } | ||
| 1901 | - } | ||
| 1884 | + *Delegates.Py_NoSiteFlag = 1; | ||
| 1885 | + return *Delegates.Py_NoSiteFlag; | ||
| 1886 | + }); | ||
| 1902 | 1887 | } | |
| 1903 | 1888 | ||
| 1904 | 1889 | internal static class Delegates | |
@@ -2170,6 +2155,7 @@ static Delegates() | |||
| 2170 | 2155 | catch (MissingMethodException) { } | |
| 2171 | 2156 | ||
| 2172 | 2157 | PyType_Type = GetFunctionByName(nameof(PyType_Type), GetUnmanagedDll(_PythonDll)); | |
| 2158 | + Py_NoSiteFlag = (int*)GetFunctionByName(nameof(Py_NoSiteFlag), GetUnmanagedDll(_PythonDll)); | ||
| 2173 | 2159 | } | |
| 2174 | 2160 | ||
| 2175 | 2161 | static global::System.IntPtr GetUnmanagedDll(string? libraryName) | |
@@ -2426,6 +2412,7 @@ static Delegates() | |||
| 2426 | 2412 | internal static delegate* unmanaged[Cdecl]<BorrowedReference, void> _Py_NewReference { get; } | |
| 2427 | 2413 | internal static delegate* unmanaged[Cdecl]<int> _Py_IsFinalizing { get; } | |
| 2428 | 2414 | internal static IntPtr PyType_Type { get; } | |
| 2415 | + internal static int* Py_NoSiteFlag { get; } | ||
| 2429 | 2416 | } | |
| 2430 | 2417 | } | |
| 2431 | 2418 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments