FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

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

PyIter: do not force dispose previous object upon moving to the next one - #1331

Merged
filmor merged 1 commit into
pythonnet:masterfrom
losttech:PyIterFixes
Dec 18, 2020
Merged

PyIter: do not force dispose previous object upon moving to the next one#1331
filmor merged 1 commit into
pythonnet:masterfrom
losttech:PyIterFixes

Conversation

lostmsu commented Dec 17, 2020

Copy link
Copy Markdown
Member

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

Comment thread src/runtime/runtime.cs
@@ -1855,6 +1855,8 @@ internal static bool PyIter_Check(IntPtr pointer)

[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyIter_Next(IntPtr pointer);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Do we still need this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, there are still a few uses.

also added exception handling for PyIter_Next

PyObject now implements `IEnumerable<PyObject>`
filmor merged commit 7149d5e into pythonnet:master Dec 18, 2020
lostmsu deleted the PyIterFixes branch December 18, 2020 20:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL