GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix crash when event does not have `Add` method and improve message for some other internal errors by lostmsu · Pull Request #2409 · pythonnet/pythonnet

Conversation

@lostmsu

@lostmsu 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.

  • Updated the CHANGELOG

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lostmsu

lostmsu commented Jul 2, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

filmor
filmor approved these changes Jul 2, 2024
View reviewed changes
@filmor

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

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#.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lostmsu
lostmsu deleted the InternalError branch July 2, 2024 22:11
@dependabot 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

Reviewers

@filmor filmor filmor approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@filmor filmor

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@lostmsu @filmor
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.