Skip to content

Commit f000e08

Browse files
committed
Explain for getting _PyObject_NextNotImplemented
1 parent d1928dc commit f000e08

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/runtime/runtime.cs

+4
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ internal static void Initialize(bool initSigs = false)
304304

305305
IntPtr dllLocal = IntPtr.Zero;
306306

307+
// Since `_PyObject_NextNotImplemented` would set to a heap class
308+
// for tp_iternext which doesn't implement __next__.
309+
// Thus we need a heap class to get it, the ZipImportError is a
310+
// heap class and it's in builtins, so we can use it as a trick.
307311
var zipimport = PyImport_ImportModule("zipimport");
308312
var ZipImportError = PyObject_GetAttrString(zipimport, "ZipImportError");
309313
_PyObject_NextNotImplemented = Marshal.ReadIntPtr(ZipImportError, TypeOffset.tp_iternext);

0 commit comments

Comments
 (0)