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
Check type getitem #5549
Check type getitem #5549
Conversation
Check that calls to `Type.__getitem__` are slices with no start or stop (e.g. `intp[:]`). Raises a KeyError if not. Previously, `list(intp)` would infinite loop.
Thanks for the PR, much appreciated. Looks like there's a couple of test fails on CI at present, marked as "In progress". |
Yeah there are several places that depend on the old behavior that I need to fix still. I wanted to see what you thought about it, or if there were any valid use cases of indexing by something other than an open slice that I'm not aware of. |
From `BaseTuple.from_types` we can pass a list of types as well
@stuartarchibald I think the CI errors are fixed. |
Thanks for fixing, queued for review. |
@@ -257,7 +257,10 @@ def add_indices_to_kernel(self, kernel, index_names, ndim, | |||
const_index_vars[dim], loc) | |||
new_body.append(ir.Assign(getitemcall, getitemvar, loc)) | |||
# Get the type of this particular part of the index tuple. | |||
one_index_typ = stmt_index_var_typ[dim] | |||
if isinstance(stmt_index_var_typ, types.ConstSized): |
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.
Why is this change needed?
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.
nvm, I found the affected test test_basic81 (numba.tests.test_stencils.TestManyStencils)
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!
Check that calls to
Type.__getitem__
are slices with no start or stop (e.g.intp[:]
).Raises a KeyError if not.
Previously,
list(intp)
would infinite loop.