Skip to content

Added parameter validation to PyObject methods #1021

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 4 commits into from
Feb 3, 2020

Conversation

lostmsu
Copy link
Member

@lostmsu lostmsu commented Dec 19, 2019

What does this implement/fix? Explain your changes.

This adds basic validations to input parameters of various PyObject methods, which should help in debugging code, that uses Python.NET.

Also adds a few function overloads

Does this close any currently open issues?

No, but it reduces divergence with Lost Tech fork

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 to AUTHORS
  • Updated the CHANGELOG
PHP-Proxy

PHP-Proxy

Error accessing resource: 404 - Not Found

@lostmsu lostmsu force-pushed the PR/PyObjectParamValidation branch from fbd4621 to 3307496 Compare December 19, 2019 21:26
@codecov-io
Copy link

codecov-io commented Dec 20, 2019

Codecov Report

Merging #1021 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1021   +/-   ##
=======================================
  Coverage   86.71%   86.71%           
=======================================
  Files           1        1           
  Lines         301      301           
=======================================
  Hits          261      261           
  Misses         40       40
Flag Coverage Δ
#setup_linux 65.44% <ø> (ø) ⬆️
#setup_windows 71.42% <ø> (ø) ⬆️

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 3307496...91c7010. Read the comment docs.

@lostmsu lostmsu requested a review from filmor December 20, 2019 18:46
@lostmsu
Copy link
Member Author

lostmsu commented Jan 9, 2020

@filmor any chance to look at this? This is a pretty light change.

/// <summary>
/// Gets the specified attribute. If attribute is not found, returns the fallback value.
/// </summary>
public PyObject GetAttrOrElse(string name, PyObject _default)
Copy link
Member

Choose a reason for hiding this comment

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

How much would it hurt to make this behaviour the default? We are using GetAttr a lot, I think (even in this file).

Copy link
Member Author

Choose a reason for hiding this comment

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

@filmor I don't know, I don't have any legacy code :)
But that would be a breaking change in contract.

Copy link
Member Author

Choose a reason for hiding this comment

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

I decided to take this change out, so the rest could be merged.

@filmor
Copy link
Member

filmor commented Jan 10, 2020

Almost completely fine, but I'm not quite sure about the GetAttr changes, in particular since GetAttr(PyObject) is unchanged AFAICT. Will have a closer look.

@filmor filmor self-requested a review January 22, 2020 07:54
@lostmsu
Copy link
Member Author

lostmsu commented Jan 31, 2020

@filmor I decided to take the GetAttrOrElse out for now so that the rest could be merged. Created issue #1036

@filmor filmor merged commit dbb88bc into pythonnet:master Feb 3, 2020
@lostmsu lostmsu deleted the PR/PyObjectParamValidation branch February 27, 2020 21:39
AlexCatarino pushed a commit to QuantConnect/pythonnet that referenced this pull request Jun 27, 2020
* added parameter validation to PyObject methods
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.

None yet

3 participants