← Winnitude! Search  ·  Reader Mode (1810 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 57 LINKS

Fix crash when event does not have `Add` method and improve message for some other internal errors by lostmsu · Pull Request #2409 · pythonnet/pythonnet

Repository navigation

Fix crash when event does not have Add method and improve message for some other internal errors - #2409


Merged
filmor merged 3 commits into pythonnet:master from losttech:InternalError Jul 2, 2024
Merged

Fix crash when event does not have Add method and improve message for some other internal errors #2409 filmor merged 3 commits into pythonnet:master from losttech:InternalError

Conversation

lostmsu commented Jul 1, 2024



Copy link Copy Markdown
Member

What does this implement/fix? Explain your changes.

  1. Fixes crash on events with no AddMethod
  2. Adds InternalPythonnetException that can tell user what .NET type caused failure if an unexpected internal error occurs

Does this close any currently open issues?

#2405

Checklist

Check all those that are applicable and complete.

lostmsu assigned filmor Jul 1, 2024 lostmsu mentioned this pull request Jul 1, 2024 Add null checks before binding #2406 Closed lostmsu added 3 commits July 1, 2024 15:09 not all events have Add method 790b7c8
fixes pythonnet#2405
give users some idea of why we might be unable to reflect .NET types ... dfb46a6
...to Python for them
mentioned event Add method crash fix in changelog 772fa05 lostmsu force-pushed the InternalError branch from 4c0c6b2 to 772fa05
Compare
July 1, 2024 22:09

filmor commented Jul 2, 2024



Copy link Copy Markdown
Member

As said, while looking mildly prettier, this still renders the library completely useless in this case. I don't think there is any valid reason for us to bail out on init just because a single type is not loaded properly.

So, sure, we can merge this, but we can not claim that it fixes the reported issue.

lostmsu commented Jul 2, 2024 · edited Loading



Copy link Copy Markdown
Member

Author

@filmor the fix is the new null check in ShouldBindEvent.

The rest is to make it easier to do bug reports: the error data will now at least contain the name of the type that we failed to process.

filmor approved these changes Jul 2, 2024
View reviewed changes

filmor commented Jul 2, 2024



Copy link Copy Markdown
Member

I see. Still don't see why making ShouldBindEvent special in that it swallows the error instead of throwing is better than just behaving like this uniformly. I'd rather have none of these functions throw, but at least it fixes the reported issue.

filmor merged commit 9ebfbde into pythonnet : master Jul 2, 2024

lostmsu commented Jul 2, 2024



Copy link Copy Markdown
Member

Author

@filmor it does not swallow the error.

The checks on methods and fields are different. They actually check that method or field was passed, and not just null. In case of event the event itself must exist as well (e.g. not null), but some events apparently do not have a corresponding add method for handlers: AddMethod property is nullable

BTW I was unable to reproduce it with C#.

lostmsu deleted the InternalError branch July 2, 2024 22:11 dependabot
Bot
mentioned this pull request Jan 16, 2026 Bump pythonnet from 3.0.3 to 3.0.5 mattemangia/Deep3DStudio#99 Closed Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment

Labels

None yet

2 participants