Fix a crash that occurred when trying to write out a FITS file to a new file if it was originally read with denywrite#19952
Closed
astrofrog wants to merge 1 commit into
Closed
Conversation
Contributor
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
… denywrite-opened table to a new file no longer fails
1997e3a to
9d567be
Compare
saimn
reviewed
Jun 19, 2026
| # read-only buffer (e.g. a ``denywrite`` table written to a new file), | ||
| # so copy first; own-heap HDUs (compression) don't rewrite here. | ||
| if not self._manages_own_heap and not self.data.flags.writeable: | ||
| self.data = self.data.copy() |
Contributor
There was a problem hiding this comment.
The drawback of this is that people might loose the reference to data if they have one ? Not sure if there is a better thing to do though ...
If the array cannot be made writeable inplace (not sure if this is possible with the underlying mmap), maybe we can also just raise an error telling users that denywrite is not compatible with an array that needs to be modified ?
Member
Author
|
@saimn - your comment prompted me to think of what I think is a better solution here, I'll open a parallel PR |
This comment was marked as resolved.
This comment was marked as resolved.
Member
Author
|
No I've updated the labels |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If a FITS file is read in with
denywriteand the data is then written out to a different file, a crash can occur if some columns are being scaled or updated at write-time:This PR ensures that we copy the buffer before modifying if needed.
Description
Closes #19955