Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Reworked the way .NET objects are constructed from Python#1651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

lostmsu
Copy link
Member

@lostmsulostmsu commentedDec 30, 2021
edited
Loading

What does this implement/fix? Explain your changes.

Was:
tp_new implementation would call .NET constructor and return a fully constructed object

Now:
Except for some special .NET typestp_new creates uninitialized .NET object, which is later initialized by callinguninitialized_inst.__init__(...).

__init__ is set in type dictionary to aMethodObject, that containsConstructorInfo[] instead ofMethodInfo[]

This allows Python to:

  1. freely override__init__ when deriving from .NET types
  2. when doing so call base__init__ (e.g. .NET constructor), and choose the overload as needed

Failing to call base__init__ in this scenario will lead to an undefined behavior.

Does this close any currently open issues?

fixes#238

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • Updated theCHANGELOG

@lostmsulostmsuforce-pushed thebugs/DefaultConstructorFallback branch from1d8c1f4 to25a94e4CompareJanuary 4, 2022 17:34
was: tp_new implementation would call .NET constructor and return a fully constructed objectnow:Except for some special .NET types tp_new creates uninitialized .NET object, which is later initialized by calling __init__.__init__ is set using type dictionary to a MethodObject, that contains ConstructorInfo[] instead of MethodInfo[]This allows Python to:1) freely override __init__2) when deriving from .NET types call base __init__ (e.g. .NET constructor), and choose the overload as neededfixespythonnet#238
@lostmsulostmsuforce-pushed thebugs/DefaultConstructorFallback branch from25a94e4 toc091cafCompareJanuary 4, 2022 17:38
@lostmsulostmsu merged commitc4238d9 intopythonnet:masterJan 4, 2022
@lostmsulostmsu deleted the bugs/DefaultConstructorFallback branchJanuary 4, 2022 20:23
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Constructor failing argument matching, silently selects default constructor
1 participant
@lostmsu

[8]ページ先頭

©2009-2025 Movatter.jp