Skip to content
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

rpc: fix 0-ady functions raising an exception #134

Closed

Conversation

Synthetica9
Copy link

Closes #130

@@ -264,13 +264,14 @@ def _wrapMethod(K, V):
if S.varargs is not None or keywords is not None:
raise TypeError("vararg not supported for proxy method %s" % K)

if len(S.args) != len(S.defaults):
args, defaults = ([] if v is None else v for v in (S.args, S.defaults))
Copy link
Member

@mdavidsaver mdavidsaver Jan 16, 2024

Choose a reason for hiding this comment

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

Do you mean for this line to do something like the following?

args, defaults = S.args or [], S.defaults or []

Copy link
Author

Choose a reason for hiding this comment

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

Yes, but I generally don't use the or syntax to handle None because it also brakes on falsely values.

Copy link
Member

Choose a reason for hiding this comment

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

For reference, I understand the concern about loose type comparison rules. In this instance, S comes from the builtin inspect module, which I think can be relied on not to change radically. So I think the or [] is a reasonable abbreviation.

@mdavidsaver
Copy link
Member

For this PR and #131, it would be helpful to have added test coverage to TestProxy in src/p4p/test/test_rpc.py. Including cases where eg. the client-side proxy should throw an exception due to malformed call arguments.

@mdavidsaver
Copy link
Member

Thank you for this PR. However, I have applied a different fix with 4f6b9e9.

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.

rpccall with 0-ady functions fails
2 participants