{"action":"created","issue":{"url":"https://api.github.com/repos/astropy/astropy/issues/5594","repository_url":"https://api.github.com/repos/astropy/astropy","labels_url":"https://api.github.com/repos/astropy/astropy/issues/5594/labels{/name}","comments_url":"https://api.github.com/repos/astropy/astropy/issues/5594/comments","events_url":"https://api.github.com/repos/astropy/astropy/issues/5594/events","html_url":"https://github.com/astropy/astropy/issues/5594","id":195007529,"number":5594,"title":"Regression in io.fits due to undefined variable","user":{"login":"astrofrog","id":314716,"avatar_url":"https://avatars.githubusercontent.com/u/314716?v=3","gravatar_id":"","url":"https://api.github.com/users/astrofrog","html_url":"https://github.com/astrofrog","followers_url":"https://api.github.com/users/astrofrog/followers","following_url":"https://api.github.com/users/astrofrog/following{/other_user}","gists_url":"https://api.github.com/users/astrofrog/gists{/gist_id}","starred_url":"https://api.github.com/users/astrofrog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astrofrog/subscriptions","organizations_url":"https://api.github.com/users/astrofrog/orgs","repos_url":"https://api.github.com/users/astrofrog/repos","events_url":"https://api.github.com/users/astrofrog/events{/privacy}","received_events_url":"https://api.github.com/users/astrofrog/received_events","type":"User","site_admin":false},"labels":[{"id":68702403,"url":"https://api.github.com/repos/astropy/astropy/labels/Affects-dev","name":"Affects-dev","color":"eb6420","default":false},{"id":16191481,"url":"https://api.github.com/repos/astropy/astropy/labels/Bug","name":"Bug","color":"eb6420","default":false},{"id":3496818,"url":"https://api.github.com/repos/astropy/astropy/labels/io.fits","name":"io.fits","color":"c7def8","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-12T15:46:04Z","updated_at":"2016-12-12T15:48:46Z","closed_at":null,"body":"@mwcraig @embray  - I'm running into the following failure in glue due to the recent changes in io.fits:\r\n\r\n```python\r\n    def _read_next_hdu(self):\r\n        \"\"\"\r\n            Lazily load a single HDU from the fileobj or data string the `HDUList`\r\n            was opened from, unless no further HDUs are found.\r\n    \r\n            Returns True if a new HDU was loaded, or False otherwise.\r\n            \"\"\"\r\n    \r\n        if self._read_all:\r\n            return False\r\n    \r\n        saved_compression_enabled = compressed.COMPRESSION_ENABLED\r\n        fileobj, data, kwargs = self._file, self._data, self._open_kwargs\r\n    \r\n        try:\r\n            self._in_read_next_hdu = True\r\n    \r\n            if ('disable_image_compression' in kwargs and\r\n                kwargs['disable_image_compression']):\r\n                compressed.COMPRESSION_ENABLED = False\r\n    \r\n            # read all HDUs\r\n            try:\r\n                if fileobj is not None:\r\n                    try:\r\n                        # Make sure we're back to the end of the last read\r\n                        # HDU\r\n                        if len(self) > 0:\r\n                            last = self[len(self) - 1]\r\n                            if last._data_offset is not None:\r\n                                offset = last._data_offset + last._data_size\r\n                                fileobj.seek(offset, os.SEEK_SET)\r\n    \r\n                        hdu = _BaseHDU.readfrom(fileobj, **kwargs)\r\n                    except EOFError:\r\n                        self._read_all = True\r\n                        return False\r\n                    except ValueError:\r\n                        # A ValueError can occur when trying to perform I/O\r\n                        # on a closed file\r\n                        if fileobj.closed:\r\n                            self._read_all = True\r\n                            return False\r\n                        else:\r\n                            raise\r\n                    except IOError:\r\n                        if fileobj.writeonly:\r\n                            self._read_all = True\r\n                            return False\r\n                        else:\r\n                            raise\r\n                else:\r\n                    if not data:\r\n                        self._read_all = True\r\n                        return False\r\n                    hdu = _BaseHDU.fromstring(data, **kwargs)\r\n                    self._data = data[hdu._data_offset + hdu._data_size:]\r\n    \r\n                super(HDUList, self).append(hdu)\r\n                if len(self) == 1:\r\n                    # Check for an extension HDU and update the EXTEND\r\n                    # keyword of the primary HDU accordingly\r\n                    self.update_extend()\r\n    \r\n                hdu._new = False\r\n                if 'checksum' in kwargs:\r\n                    hdu._output_checksum = kwargs['checksum']\r\n            # check in the case there is extra space after the last HDU or\r\n            # corrupted HDU\r\n            except (VerifyError, ValueError) as exc:\r\n                warnings.warn(\r\n                    'Error validating header for HDU #{} (note: Astropy '\r\n                    'uses zero-based indexing).\\n{}\\n'\r\n                    'There may be extra bytes after the last HDU or the '\r\n                    'file is corrupted.'.format(\r\n>                       len(hdulist), indent(str(exc))), VerifyWarning)\r\nE                       NameError: global name 'hdulist' is not defined\r\n\r\n../../../miniconda/envs/test/lib/python2.7/site-packages/astropy/io/fits/hdu/hdulist.py:1150: NameError\r\n============================ pytest-warning summary ============================\r\n```"},"comment":{"url":"https://api.github.com/repos/astropy/astropy/issues/comments/266465671","html_url":"https://github.com/astropy/astropy/issues/5594#issuecomment-266465671","issue_url":"https://api.github.com/repos/astropy/astropy/issues/5594","id":266465671,"user":{"login":"mwcraig","id":1147167,"avatar_url":"https://avatars.githubusercontent.com/u/1147167?v=3","gravatar_id":"","url":"https://api.github.com/users/mwcraig","html_url":"https://github.com/mwcraig","followers_url":"https://api.github.com/users/mwcraig/followers","following_url":"https://api.github.com/users/mwcraig/following{/other_user}","gists_url":"https://api.github.com/users/mwcraig/gists{/gist_id}","starred_url":"https://api.github.com/users/mwcraig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwcraig/subscriptions","organizations_url":"https://api.github.com/users/mwcraig/orgs","repos_url":"https://api.github.com/users/mwcraig/repos","events_url":"https://api.github.com/users/mwcraig/events{/privacy}","received_events_url":"https://api.github.com/users/mwcraig/received_events","type":"User","site_admin":false},"created_at":"2016-12-12T15:48:46Z","updated_at":"2016-12-12T15:48:46Z","body":"I can fix up later today as part of #5589  or someone could push to that branch. Looks like an easy fix, but a regression test should be added for it too.\r\n\r\nOr a separate PR, of course."}}
{"actor":{"display_login":"mwcraig"}}