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

[Out] parameters no longer added to return tuple#1308

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
filmor merged 1 commit intopythonnet:masterfromlosttech:PR/OutMarshaling
Dec 8, 2020

Conversation

@lostmsu
Copy link
Member

@lostmsulostmsu commentedDec 8, 2020
edited
Loading

Parameters marked withParameterAttributes.Out (aka[Out]) are no longer returned in addition to the regular method return value (unless they are passed withref orout keyword).

What does this implement/fix? Explain your changes.

As it is now possible to pass raw .NET objects to .NET methods, there's no need to marshal[Out] parameters back to Python manually. Python users can simply access modified object's data directly.

Any other comments?

It was confusing to seeread, _ = stream.Read(buff, 0, buff.Length) in the test code, asRead method does not really have anyout orref parameters. It also failed on some .NET implementations, as the corresponding parameter does not always have an[Out] attribute.

Related issues

This should unblock#1307 (tests there are failing because of this difference).

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

…ed in addition to the regular method return value (unless they are passed with `ref` or `out` keyword).
@filmor
Copy link
Member

I think this was included for compatibility with IronPython. How would you handle out parameters that still have automatic conversions likeint andstr?

@codecov-io
Copy link

codecov-io commentedDec 8, 2020
edited
Loading

Codecov Report

Merging#1308 (ff89811) intomaster (57f4a80) willdecrease coverage by13.84%.
The diff coverage isn/a.

Impacted file tree graph

@@             Coverage Diff             @@##           master    #1308       +/-   ##===========================================- Coverage   87.88%   74.04%   -13.85%===========================================  Files           1        1                 Lines         289      289               ===========================================- Hits          254      214       -40- Misses         35       75       +40
FlagCoverage Δ
setup_linux?
setup_windows74.04% <ø> (ø)

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

Impacted FilesCoverage Δ
setup.py74.04% <0.00%> (-13.85%)⬇️

Continue to review full report at Codecov.

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

@lostmsu
Copy link
MemberAuthor

lostmsu commentedDec 8, 2020
edited
Loading

@filmor this is the confusing part. This change does not affectGetInt(out int val) functions. It affectsGetInt([Out] int val) functions, where[Out] parameter does nothing. The only real use case I see is that inRead([Out] byte[] buf)[Out] indicates, that the data will be put into thebuf. The data can not be put intostring orint withoutref int/out int, and these are handled separately.

This annotation is normally meant for P/Invoke marshaling scenarios, where you have to add[Out] tobyte[] arr into PInvoke signature for data to be properly marshaled back intoarr upon exiting C function. I am not even sure whyMemoryStream.Read has this annotation except for informational purposes. I believe passing Python lists in place ofbuf is why it was added, but considering lack of[Out] annotations in most places, I don't think it is a good thing to rely on.

filmor reacted with thumbs up emoji

@lostmsu
Copy link
MemberAuthor

lostmsu commentedDec 8, 2020
edited
Loading

For an instance of API difference between implementations in regards to[Out] attribute:

In .NET CoreMemoryStream.Read has none:https://github.com/dotnet/runtime/blob/5432a66018c2499b88a54276f468ea903ed2b8de/src/libraries/System.Private.CoreLib/src/System/IO/MemoryStream.cs#L333

In Mono it is present for COM-compatibility:https://github.com/mono/mono/blob/c5b88ec4f323f2bdb7c7d0a595ece28dae66579c/mcs/class/referencesource/mscorlib/system/io/memorystream.cs#L339

Without this change the same Python code would not work with both Mono and .NET Core.

@filmorfilmor merged commit5b09ba6 intopythonnet:masterDec 8, 2020
@filmor
Copy link
Member

Thanks for the explanation. I ran into this problem while testing .NET Core and couldn't really make sense of it, wasn't aware of[Out].

@lostmsulostmsu deleted the PR/OutMarshaling branchDecember 8, 2020 23:11
@lostmsulostmsu mentioned this pull requestDec 18, 2020
4 tasks
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.

3 participants

@lostmsu@filmor@codecov-io

[8]ページ先頭

©2009-2025 Movatter.jp