`fromfile` should raise an exception if not passed a “low-level file”
See original GitHub issueAn ancient ticket from 2007 notes that fromfile
does not work with files opened with gzip. Instead, it will interpret the literal gzip data. This is due to the fundamental way fromfile
works and the resolution of the bug was essentially wontfix.
Secondly, it should be made clear in the documentation that you cannot pass a GzipFile
. Some file-like objects trigger io.UnsupportedOperation
.
It may save bugs and headaches if fromfile
were to raise an Exception if it is passed a file-object that is not a low-level file.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:20 (16 by maintainers)
Top Results From Across the Web
The GNU C Library - Documentation
This happens transparently for the user since all of the lowlevel file handling functions are equally replaced. This function is a cancellation point...
Read more >The GNU C Library - ftp://ftp.gnu.org
This happens transparently for the user since all of the lowlevel file handling functions are equally replaced. This function is a cancellation point...
Read more >Python Pocket Reference 978-1449357016 - DOKUMEN.PUB
Indicates that anything else on the command line is passed to the script file or ... Intended for lowlevel file tasks only; not...
Read more >Hack7 Section 4 | PDF | Division (Mathematics) | Class (Computer ...
FCREATE() creates a file on disk, and returns a "handle"a numeric value that other lowlevel file functions must have to refer to the...
Read more >capsule.txt - ftpmirror.your.org
[CP/M-80:BDS] If the two files are not the same length, FILECOMP will ... Routines to do lowlevel file l/O. Includes functions to seek,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is there any reason not to implement this so it actually works? It’s been ten years since the bug was initially reported, and it’s still hurting people–for example https://stackoverflow.com/questions/47574607/python-gzip-module-doesnt-work-as-expected-on-ubyte-file/
It seems to me that it is possible to implement
np.fromfile()
so that it works withGzipFile
(but not usingreadinto()
).I think I agree with the consensus here that we should probably reopen this. Since closed issues are hard to rediscover, I’m going to reopen it for now - we can always close it again if another maintainer wants to argue strongly for it.
For every ancient issue we close with opposition, there are 10 which are unreproducible/irrelevant/already fixed - so it’s easy to be overzealous with closing,
Sometimes I wish we had fewer APIs for serialization / deserialization, especially for text formats…