{"action":"created","issue":{"url":"https://api.github.com/repos/astropy/astropy/issues/7980","repository_url":"https://api.github.com/repos/astropy/astropy","labels_url":"https://api.github.com/repos/astropy/astropy/issues/7980/labels{/name}","comments_url":"https://api.github.com/repos/astropy/astropy/issues/7980/comments","events_url":"https://api.github.com/repos/astropy/astropy/issues/7980/events","html_url":"https://github.com/astropy/astropy/issues/7980","id":374449177,"node_id":"MDU6SXNzdWUzNzQ0NDkxNzc=","number":7980,"title":"astropy.io.fits error with getdata(), stream-like object, and mode='readonly'","user":{"login":"at88mph","id":1671908,"node_id":"MDQ6VXNlcjE2NzE5MDg=","avatar_url":"https://avatars1.githubusercontent.com/u/1671908?v=4","gravatar_id":"","url":"https://api.github.com/users/at88mph","html_url":"https://github.com/at88mph","followers_url":"https://api.github.com/users/at88mph/followers","following_url":"https://api.github.com/users/at88mph/following{/other_user}","gists_url":"https://api.github.com/users/at88mph/gists{/gist_id}","starred_url":"https://api.github.com/users/at88mph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/at88mph/subscriptions","organizations_url":"https://api.github.com/users/at88mph/orgs","repos_url":"https://api.github.com/users/at88mph/repos","events_url":"https://api.github.com/users/at88mph/events{/privacy}","received_events_url":"https://api.github.com/users/at88mph/received_events","type":"User","site_admin":false},"labels":[{"id":3496818,"node_id":"MDU6TGFiZWwzNDk2ODE4","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":13,"created_at":"2018-10-26T16:04:34Z","updated_at":"2018-10-26T20:52:54Z","closed_at":null,"author_association":"NONE","body":"I'm using a call to `getdata()` to pull a single HDU from an input stream.  The stream does not implement a `write()` method, and nor would I expect it to, but I get this error with `getdata()`:\r\n\r\n```\r\nhdu = getdata(file_stream, header=True, ext=2, memmap=True, do_not_scale_image_data=True)\r\n```\r\n> OSError: File-like object does not have a 'write' method, required for mode 'ostream'.\r\n\r\nI think it's related to #7533.\r\n\r\nThen I set the mode to 'readonly' in hopes of working around it, but then I get this error:\r\n\r\n```\r\nhdu = getdata(file_stream, header=True, ext=2, memmap=True, do_not_scale_image_data=True, mode='readonly')\r\n```\r\n\r\n```\r\nkwargs = {'do_not_scale_image_data': True, 'ext': 0, 'memmap': True, 'mode': 'readonly'}, mode = 'readonly', closed = False, header = True\r\nlower = None, upper = None, view = None\r\n\r\n    def getdata(filename, *args, **kwargs):\r\n...\r\n>       hdulist, extidx = _getext(filename, mode, *args, **kwargs)\r\nE       TypeError: _getext() got multiple values for keyword argument 'mode'\r\n```\r\n\r\nHow can I use a readonly stream with a stream like object?  Is the only way to omit the `mode` and wrap it in an `io.BytesIO` stream?\r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/astropy/astropy/issues/comments/433540135","html_url":"https://github.com/astropy/astropy/issues/7980#issuecomment-433540135","issue_url":"https://api.github.com/repos/astropy/astropy/issues/7980","id":433540135,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMzU0MDEzNQ==","user":{"login":"saimn","id":311639,"node_id":"MDQ6VXNlcjMxMTYzOQ==","avatar_url":"https://avatars0.githubusercontent.com/u/311639?v=4","gravatar_id":"","url":"https://api.github.com/users/saimn","html_url":"https://github.com/saimn","followers_url":"https://api.github.com/users/saimn/followers","following_url":"https://api.github.com/users/saimn/following{/other_user}","gists_url":"https://api.github.com/users/saimn/gists{/gist_id}","starred_url":"https://api.github.com/users/saimn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saimn/subscriptions","organizations_url":"https://api.github.com/users/saimn/orgs","repos_url":"https://api.github.com/users/saimn/repos","events_url":"https://api.github.com/users/saimn/events{/privacy}","received_events_url":"https://api.github.com/users/saimn/received_events","type":"User","site_admin":false},"created_at":"2018-10-26T20:52:54Z","updated_at":"2018-10-26T20:52:54Z","author_association":"CONTRIBUTOR","body":"Or with urllib:\r\n```\r\nIn [28]: res = urllib.request.urlopen('https://astropy.stsci.edu/data/galactic_center/gc_2mass_h.fits')                                                                              \r\n\r\nIn [29]: res                                                                                   \r\nOut[29]: <http.client.HTTPResponse at 0x7f5fed6748d0>\r\n\r\nIn [31]: fits.open(res)                                                                        \r\nOut[31]: [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x7f5fed73b780>]\r\n```"}}
{"actor":{"display_login":"saimn"}}