Skip to content

script 'fitscheck' not deleting CHECKSUM and DATASUM keywords #5874

Description

@mohanagr

Astropy v2.0

While working on #5858 I am seeing this particular behavior for fitscheck :-

  • Running fitscheck -v test0.fits (A test file included in astropy/io/fits/tests/data/) which works fine
MISSING './astropy/io/fits/tests/data/test0.fits' .. Checksum not found in HDU #0
1 errors
  • Running fitscheck -v --force --write test0.fits (write correct checksums and datasums for each HDU in file)
MISSING './astropy/io/fits/tests/data/test0.fits' .. Checksum not found in HDU #0
1 errors

Fine too. It first warns then updates

  • Now when I run fitscheck -v --checksum none --write (seeing call trace manually)
AttributeError: 'PrimaryHDU' object has no attribute '_checksum'

This comes from (https://github.com/astropy/astropy/blob/master/astropy/io/fits/scripts/fitscheck.py#L143)

As a matter of fact now that I've added checksums above, it verifies them successfully when I run fitscheck -v test0.fits :-

OK './astropy/io/fits/tests/data/test0.fits'

Is there something I'm missing? Or should I go ahead try to correct this.

Edit : This AttributeError is raised whenever one uses -k none or --checksum none

Activity

  1. changed the title [-]script `fitscheck` not deleting `CHECKSUM` and `DATASUM` keywords[/-] [+]script 'fitscheck' not deleting CHECKSUM and DATASUM keywords[/+] on Mar 11, 2017
  2. mohanagr commented on Mar 12, 2017

    @mohanagr
    ContributorAuthor

    After some digging here's what I think the issue is :-

    In order for the CHECKSUM and DATASUM keywords to be removed, the checksum kwarg should be passed as HDUList.writeto(checksum='remove') not False as is done by the Fitscheck script.
    (https://github.com/astropy/astropy/blob/master/astropy/io/fits/scripts/fitscheck.py#L112)
    Since this calls base._prewriteto() -> base._update_checksum() which deletes only when remove is the kwarg.

    Now, as for the error raised, it is raised only when one uses -k none option as I have highlighted in the issue. This is because in (https://github.com/astropy/astropy/blob/master/astropy/io/fits/scripts/fitscheck.py#L135)
    There we open the fits file, the call stack terminates at base._readfrom_internal() which is supposed to call _verify checksum_datasum (which sets hdu._checksum ) but doesn't because the script option "none" sets the checksum kwarg to False. Check the reference below.
    Reference
    (https://github.com/astropy/astropy/blob/master/astropy/io/fits/hdu/base.py#L460)

  3. mohanagr commented on Mar 12, 2017

    @mohanagr
    ContributorAuthor

    @saimn @pllim Should I open a different PR for this or push it in #5858 where I was writing tests for fitscheck ? Thanks.

  4. added a commit that references this issue on Mar 12, 2017
  5. pllim commented on Mar 13, 2017

    @pllim
    Member

    I would say bug fix should be a separate PR from adding tests because they are milestoned differently, but looks like you already added the fix into the testing PR.

  6. added a commit that references this issue on Mar 14, 2017
  7. bsipocz commented on Sep 25, 2017

    @bsipocz
    Member

    Closing, see #6571 for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions