Skip to content

Conversation

@charris
Copy link
Member

@charris charris commented Jul 24, 2022

Backport of #21925.

This would be the minimal fix for gh-21911 (and an older issue somewhere). However, it would also set a precedence that subarray to object casts will create copies.
That is likely fine, since those casts usually crashed for a while and in many places a copy is OK. It was also always broken from an ownership perspective.
However, for code that used this and assigned to the result, things would obviously change.

There are three options:

  1. Less-minimal fix, because we want view behavior here (and fix it).
  2. Keep it as it is (it was so unreliable that failures are hopefully minimal, and why would one cast to object to then assign?).
  3. We could tag on a warning, I don't think the warning "flag" is used right now. I.e. print out a UserWarning that this is a copy, but may have been a view whenever the array may be written to. (This may not be quite reliable for buffer users like cython, but not sure.)

@charris charris added 00 - Bug 08 - Backport Used to tag backport PRs labels Jul 24, 2022
@charris charris added this to the 1.23.2 release milestone Jul 24, 2022
@charris charris merged commit 5e80d8e into numpy:maintenance/1.23.x Jul 24, 2022
@charris charris deleted the backport-21925 branch July 24, 2022 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

00 - Bug 08 - Backport Used to tag backport PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants