PyIter: do not force dispose previous object upon moving to the next one by lostmsu · Pull Request #1331 · pythonnet/pythonnet

What does this implement/fix? Explain your changes.

Prior to this change trying to use object returned by iterating over PyObject would fail after iterator is closed, because iterator would dispose previously returned objects on close/moving to the next one.

This also adds error handling for PyIter_Next calls, which can have other reasons to fail beyond reaching the end of collection.

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Add yourself to AUTHORS
  • Updated the CHANGELOG