Skip to content

Allow borrowing from NewReference #1088

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2020

Conversation

lostmsu
Copy link
Member

@lostmsu lostmsu commented Mar 11, 2020

implemented as an implicit conversion

To be honest, I would prefer an explicit NewReference.Borrow() method due to "explicit is better than implicit" motto. The only problem with implicit conversion that I see is new PyObject(newRef) will call an extra incref implicitly as opposed to newRef.MoveToPyObject(), and will go unnoticed.

Another thing to consider is having a null-check in the conversion. E.g. should we throw NullReferenceException if NewReference is null?

Does this close any currently open issues?

Related to #1087

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

implemented as an implicit conversion
@lostmsu lostmsu mentioned this pull request Mar 11, 2020
4 tasks
@codecov-io
Copy link

codecov-io commented Mar 11, 2020

Codecov Report

Merging #1088 into master will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1088   +/-   ##
=======================================
  Coverage   86.75%   86.75%           
=======================================
  Files           1        1           
  Lines         302      302           
=======================================
  Hits          262      262           
  Misses         40       40           
Flag Coverage Δ
#setup_linux 65.56% <ø> (ø)
#setup_windows 71.52% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d145ab1...0f03624. Read the comment docs.

@lostmsu
Copy link
Member Author

lostmsu commented Mar 16, 2020

@amos402 can you review this?

@lostmsu lostmsu merged commit 638dc1c into pythonnet:master Mar 17, 2020
@lostmsu lostmsu deleted the features/BorrowFromNewReference branch March 17, 2020 06:22
@lostmsu
Copy link
Member Author

lostmsu commented Mar 18, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants