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

Make indexers work for interface objects#1246

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
lostmsu merged 2 commits intopythonnet:masterfromdanabr:interface-indexers
Oct 6, 2020

Conversation

danabr
Copy link
Contributor

@danabrdanabr commentedOct 5, 2020
edited
Loading

What does this implement/fix? Explain your changes.

Makes the following work instead of throwing an exception:

fromSystem.Collections.GenericimportDictionary,IDictionaryd=IDictionary[str,str](Dictionary[str,str]())d["one"]="1"assertd["one"]=="1"

Does this close any currently open issues?

No

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 toAUTHORS
  • Updated theCHANGELOG

lostmsu reacted with thumbs up emoji
@codecov-commenter
Copy link

codecov-commenter commentedOct 5, 2020
edited
Loading

Codecov Report

Merging#1246 intomaster willnot change coverage.
The diff coverage isn/a.

Impacted file tree graph

@@           Coverage Diff           @@##           master    #1246   +/-   ##=======================================  Coverage   86.25%   86.25%           =======================================  Files           1        1             Lines         291      291           =======================================  Hits          251      251             Misses         40       40
FlagCoverage Δ
#setup_linux64.94% <ø> (ø)
#setup_windows72.50% <ø> (ø)

Flags with carried forward coverage won't be shown.Click here to find out more.


Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last update03cf4ac...12fdaab. Read thecomment docs.

Copy link
Member

@lostmsulostmsu left a comment
edited
Loading

Choose a reason for hiding this comment

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

Two things related to each other:

  1. Please, add a negative test (if one does not exist yet). E.g. construct an emptySystem.Object, and ensure Python can't index it for read or write.
  2. Consider only assigningmp*_subscript slots only when the type actually supports indexing like you did withtp_next.

Makes the following work instead of throwing an exception:```pythonfrom System.Collections.Generic import Dictionary, IDictionaryd = IDictionary[str, str](Dictionary[str, str]())d["one"] = "1"assert d["one"] == "1"```
@danabr
Copy link
ContributorAuthor

I've added the two things you asked for.

The erasing of the slots is ugly. We should consider movingInitializeSlots intoManagedObject and its descendants instead, so that you would just doimpl.InitializeSlots(type), and each type could handle its own initialization.

@lostmsu
Copy link
Member

Great, thanks!

I agree onInitializeSlots. If you'd like to work on that, you can start with a draft request demonstrating an approach for any one kind ofManagedObject (it does not have to pass tests or compile). Otherwise we'll just keep that in mind.

Overall it might make sense to move the majority ofTypeManager type creation functionality intoManagedObject and deriving classes, includingPyType construction. But we better do that along with the migration toPyType_FromSpec.

@lostmsulostmsu merged commitf808166 intopythonnet:masterOct 6, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@lostmsulostmsulostmsu approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@danabr@codecov-commenter@lostmsu

[8]ページ先頭

©2009-2025 Movatter.jp