Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Explain for getting _PyObject_NextNotImplemented
  • Loading branch information
amos402 committed Jun 13, 2019
commit f000e0846407a5f0a8c30b612b3c874981330feb
4 changes: 4 additions & 0 deletions src/runtime/runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ internal static void Initialize(bool initSigs = false)

IntPtr dllLocal = IntPtr.Zero;

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