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

BUG: Ignore fewer errors during array-coercion #17817

Merged
merged 1 commit into from Dec 16, 2020

Conversation

seberg
Copy link
Member

@seberg seberg commented Nov 21, 2020

This changes it so that we only ignore attribute errors on
looking up __array__ and propagate errors when checking
for sequences len(obj) if those errors are either
RecursionError or MemoryError (we consider them unrecoverable).

Also adds test for bad recursive array-like with sequence
as reported in gh-17785. The test might be flaky/more complicated
in which case it should probably just be deleted.


OK, one more attempt with raising more erros... First attempt with checking for RecursionError in the test, but lets see...

@seberg seberg force-pushed the test-bad-array-like branch 2 times, most recently from d3bea0e to 3067ada Compare November 21, 2020 17:21
This changes it so that we only ignore attribute errors on
looking up `__array__` and propagate errors when checking
for sequences `len(obj)` if those errors are either
RecursionError or MemoryError (we consider them unrecoverable).

Also adds test for bad recursive array-like with sequence
as reported in numpygh-17785. The test might be flaky/more complicated
in which case it should probably just be deleted.
@mattip
Copy link
Member

mattip commented Dec 16, 2020

LGTM. Can we put this in soon, it is holding gh-17786 back.

@mattip
Copy link
Member

mattip commented Dec 16, 2020

I think this closes gh-17785

@seberg
Copy link
Member Author

seberg commented Dec 16, 2020

@mattip it seems to close it in most cases, but I tried incorporating it in CI here and there were always some ways it still came back to bite. Although, maybe on master it at least crashes only with a fatal python error and not with a stack overflow (I don't remember).

@mattip mattip merged commit c4693fe into numpy:master Dec 16, 2020
@mattip
Copy link
Member

mattip commented Dec 16, 2020

Thanks @seberg

@seberg seberg added the 09 - Backport-Candidate PRs tagged should be backported label Dec 17, 2020
@seberg
Copy link
Member Author

seberg commented Dec 17, 2020

If we look at gh-17786 for 1.19.5 – mitigating gh-17785 partially – we definitely should backport this to 1.20.x, so marking (I think it is pretty safe anyway, although it goes a bit further than that).

@seberg seberg deleted the test-bad-array-like branch December 17, 2020 16:25
@charris charris added component: numpy._core and removed 09 - Backport-Candidate PRs tagged should be backported labels Dec 18, 2020
@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Dec 21, 2020
@charris charris added this to the 1.19.5 release milestone Dec 21, 2020
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Dec 21, 2020
@charris charris removed this from the 1.19.5 release milestone Dec 21, 2020
seberg added a commit to seberg/numpy that referenced this pull request Jan 20, 2021
Closes (the later point) in numpygh-17965 and reverts parts of
numpygh-17817.
Shapely did rely on being able to raise a NotImplementedError
which then got ignored in the attribute lookup.
Arguably, this should probably just raise an AttributeError to
achieve that behaviour, but it means we can't just rip the band-aid
off here.

Since 1.20 is practically released, just reverting most of the change
(leaving only recursion and memory error which are both arguably
pretty fatal).
Ignoring most errors should be deprecated (and I am happy to do so),
but it is not important enough for 1.20 or very important in itself.

Closes numpygh-17965
charris pushed a commit to charris/numpy that referenced this pull request Jan 21, 2021
Closes (the later point) in numpygh-17965 and reverts parts of
numpygh-17817.
Shapely did rely on being able to raise a NotImplementedError
which then got ignored in the attribute lookup.
Arguably, this should probably just raise an AttributeError to
achieve that behaviour, but it means we can't just rip the band-aid
off here.

Since 1.20 is practically released, just reverting most of the change
(leaving only recursion and memory error which are both arguably
pretty fatal).
Ignoring most errors should be deprecated (and I am happy to do so),
but it is not important enough for 1.20 or very important in itself.

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

Successfully merging this pull request may close these issues.

None yet

3 participants