Skip to content

[#5408] Don't re-verify invalid FITS cards after their values have been replaced - #11108

Merged
embray merged 3 commits into
astropy:masterfrom
embray:issue-5408
Dec 31, 2020
Merged

embray merged 3 commits into
astropy:masterfrom
embray:issue-5408

Conversation

@embray

@embray embray commented Nov 30, 2020

Copy link
Copy Markdown
Member

Fixes #5408.

Fixing this was not so easy because it once again ran up against the huge mess that is FITS card parsing and verification. If I could I would rewrite the whole thing from scratch.

@saimn saimn added this to the v4.0.5 milestone Nov 30, 2020
Comment thread astropy/io/fits/tests/test_header.py Outdated
@saimn

saimn commented Nov 30, 2020

Copy link
Copy Markdown
Contributor

Looks good, thanks @embray ! Needs a changelog though.

Move handling of CONTINUE cards into Card._split() which now parses
the value/comment portions of CONTINUE cards into a long

"'string' / comment"

string which can be parsed as though it were one long value+comment
portion of a card.

This removes the need to do this from _parse_value and _parse_comment.
I had to rework how Card._verify works: Normally the run_option method,
when passed a fix= argument, runs the fix code immediately.  However,
the fix code can have side-effects that modify the behavior of the
later verifications, which makes reasoning about _verify very difficult.

So I changed it so that it first collects a list of errors (and
potentially errors to fix) and then runs the fixes collectively at the
end.  It would probably be better if that were the way verify() worked
in general, but that is a larger refactoring job to leave for later
(possibly can wait until astropy#3668).
@embray

embray commented Dec 31, 2020

Copy link
Copy Markdown
Member Author

This was positively reviewed other than missing a changelog entry so I'll go ahead and merge.

@embray
embray merged commit 1fa5a2a into astropy:master Dec 31, 2020
@embray
embray deleted the issue-5408 branch December 31, 2020 14:39
astrofrog pushed a commit that referenced this pull request Mar 16, 2021
[#5408] Don't re-verify invalid FITS cards after their values have been replaced
pllim pushed a commit to pllim/astropy that referenced this pull request Mar 24, 2021
[astropy#5408] Don't re-verify invalid FITS cards after their values have been replaced
pllim pushed a commit to pllim/astropy that referenced this pull request Mar 25, 2021
[astropy#5408] Don't re-verify invalid FITS cards after their values have been replaced
saimn added a commit that referenced this pull request Mar 27, 2021
Manual backport for #11108 (Don't re-verify invalid FITS cards after their values have been replaced)
embray added a commit to embray/astropy that referenced this pull request Apr 6, 2021
It is possible in certain cases for a commentary card (HISTORY or
COMMENT) to be stored in a single Card object with a value too long to
fit in a single physical FITS card.

In these cases the logical card's "image" (its physical representation)
is multiple cards concentated together, and neither the _itersubcards()
nor _split() methods handled this case properly.

For some reason these code paths were previously avoided for these long
commentary cards, but after astropy#11108 tried to reuse _split() in more
places it did not handle this case properly.
nstarman pushed a commit to nstarman/astropy that referenced this pull request Apr 26, 2021
It is possible in certain cases for a commentary card (HISTORY or
COMMENT) to be stored in a single Card object with a value too long to
fit in a single physical FITS card.

In these cases the logical card's "image" (its physical representation)
is multiple cards concentated together, and neither the _itersubcards()
nor _split() methods handled this case properly.

For some reason these code paths were previously avoided for these long
commentary cards, but after astropy#11108 tried to reuse _split() in more
places it did not handle this case properly.
aaryapatil pushed a commit to aaryapatil/astropy that referenced this pull request May 3, 2021
It is possible in certain cases for a commentary card (HISTORY or
COMMENT) to be stored in a single Card object with a value too long to
fit in a single physical FITS card.

In these cases the logical card's "image" (its physical representation)
is multiple cards concentated together, and neither the _itersubcards()
nor _split() methods handled this case properly.

For some reason these code paths were previously avoided for these long
commentary cards, but after astropy#11108 tried to reuse _split() in more
places it did not handle this case properly.
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.

FITS headers don't update immediately?

3 participants