question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error message generated when you pass fits.open bytes instead of string-like is confusing.

See original GitHub issue

I unintentionally passed fits.open a bytes object instead of str-like object the error that is generated doesn’t really indicated if it is unsupported? If it is supposed to be supported then I’ve found a bug. Code below shows minimal example of how to reproduce if you have a fits file handy.

pathtofits = "<path to a fits file>"
hdus = fits.open(pathtofits) #Works perfectly

hdus = fits.open(pathtofits.encode()) #Crash

<large stack trace>

OSError: File-like object does not have a 'write' method, required for mode 'ostream'.

OS: macOS 10.12.6 Python: 3.6.2 Astropy: 2.0.2

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
MSeifert04commented, Oct 26, 2017
0reactions
drdavellacommented, Oct 26, 2017

@samaloney yes TestFileFunctions would be a good place to add this test. It would also be useful to add a writeto test as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FITS File Handling (astropy.io.fits)
The open function returns an object called an HDUList which is a list -like collection of HDU objects. An HDU (Header Data Unit)...
Read more >
What's the correct way to convert bytes to a hex string in ...
I see claims of a bytes.hex method, bytes.decode codecs, and have tried other possible functions of least astonishment without avail. I just want...
Read more >
4. Text versus Bytes - Fluent Python [Book] - O'Reilly
Implicit conversion of byte sequences to Unicode text is a thing of the past. This chapter deals with Unicode strings, binary sequences, and...
Read more >
astropy.io.fits FAQ
Astropy crashed and output a long string of code. What do I do? Why does opening a file work in CFITSIO, ds9, etc....
Read more >
Language Guide | Protocol Buffers - Google Developers
For Go, the compiler generates a .pb.go file with a type for each message type in your file. You can find out more...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found