Skip to content

BUG: fix deepcopying StringDType arrays #28643

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

Merged
merged 1 commit into from
Apr 4, 2025

Conversation

ngoldbaum
Copy link
Member

@ngoldbaum ngoldbaum commented Apr 3, 2025

Fixes #28609

@ngoldbaum
Copy link
Member Author

If anyone wants to make a fancy deepcopy traverse slot they can still do that in the future.

BTW, there's some discussion about long-term plans to make PyObject an opaque struct, which would make this sort of direct memcpy business no longer work. It's already a little questionable in the free-threaded build, since you're not supposed to move a PyMutex.

Copy link
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

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

Looks good (and makes sense).

@seberg
Copy link
Member

seberg commented Apr 4, 2025

Yes, agreed we don't have to solve the deepcopy of a custom dtype here. Thanks.

which would make this sort of direct memcpy business no longer work

Interesting, but we do need the size, no? In any-case, there are very few places we do that, and this isn't one of them. This just uses memcpy on the pointer in case the original array is unaligned.
(Seems even for the output, which is unnecessary, but harmless.)

@seberg seberg merged commit a342bf3 into numpy:main Apr 4, 2025
71 of 73 checks passed
charris pushed a commit to charris/numpy that referenced this pull request Apr 5, 2025
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Apr 5, 2025
charris pushed a commit to charris/numpy that referenced this pull request Apr 5, 2025
charris added a commit that referenced this pull request Apr 5, 2025
BUG: fix deepcopying StringDType arrays (#28643)
MaanasArora pushed a commit to MaanasArora/numpy that referenced this pull request Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Crash with copy.deepcopy when using StringDType
4 participants