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
Fixes for overload_method #3704
Conversation
Failing on Python 2.7:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch. I've tried it out and it seems to fix the problem, it also unblocks #3468. Couple of minor queries to resolve then good for merge.
numba/typing/templates.py
Outdated
def _adjust_omitted_args(argtypes, argvals): | ||
"""Add dummy arguments for each missing types.Omitted in *argtypes*. | ||
""" | ||
if len(argtypes) > len(argvals): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this branch ever executed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, kwargs support requires this branch to patch the arguments. When the signature contains Omitted types, those locations are missing in the actual arguments. This re-adds them as required by anything base on Dispatcher
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm, the added unit tests do not seem to trip this branch, and if I edit the code locally to remove the call to the branch (i.e. revert the change on this line https://github.com/numba/numba/pull/3704/files#diff-d403faa8b837ae083d77e0cba8abd6c7R648) the unit tests for numba.tests.test_extending
still pass, can you reproduce this effect? If you can, I'm wondering, practically, how to trip this....?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right. It turns out adjusting the pysignature fixes the actual problem already.
numba/typing/templates.py
Outdated
@@ -627,7 +645,7 @@ def method_impl(context, builder, sig, args): | |||
call = context.get_function(disp_type, sig) | |||
# Link dependent library | |||
context.add_linking_libs(getattr(call, 'libs', ())) | |||
return call(builder, args) | |||
return call(builder, _adjust_omitted_args(sig.args, args)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of scope so new ticket added... this needs enhancing to also do validation #3708, it was too easy to create invalid overloads when testing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fixes. Looks good. Can be merged once CI passes.
Fix #3489.
overload_method
now supports keyword arguments.Fix #3683. attribute dispatcher cache will consider the argument types.